From 8bbda55d3ce002c138f66914d89f5dadbb01dcaa Mon Sep 17 00:00:00 2001 From: "flyingscorpio@arch-desktop" Date: Tue, 21 Apr 2020 19:40:14 +0200 Subject: [PATCH] Add define OS --- install.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/install.py b/install.py index d1256a5..a1999b1 100755 --- a/install.py +++ b/install.py @@ -24,6 +24,7 @@ class Installer: ) self.base_dir = Path.getcwd() self.home = Path("~").expanduser() + self.operating_system = define_os() self.force = force self.update = update @@ -106,7 +107,7 @@ class Installer: if executable: p_dest.chmod(0o755) - def do_run(self, command: str, condition: str = 'true') -> None: + def do_run(self, command: str, condition: str = "true") -> None: """Run a command.""" if not self.evaluate_condition(condition): @@ -212,6 +213,23 @@ class Installer: ui.info() +def define_os() -> str: + """Define what OS we are using. Defaults to Arch Linux.""" + + os_release = Path("/etc/os-release") + + oses = ("debian", "arch") + + for operating_system in oses: + if operating_system in os_release.read_text().lower(): + ui.info_3("Found", operating_system) + + return operating_system + + ui.warning("Operating system wasn't found") + + return input("What is it ? ") + def main() -> None: """Parse args and instantiate the Installer."""