From 7ace1385b402409e96b70be058fb974b128e5e04 Mon Sep 17 00:00:00 2001 From: "flyingscorpio@pinebook-pro" Date: Mon, 20 Apr 2020 10:27:38 +0200 Subject: [PATCH] Add condition to run command --- install.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/install.py b/install.py index b36ba9e..925eb39 100755 --- a/install.py +++ b/install.py @@ -89,9 +89,12 @@ class Installer: if executable: p_dest.chmod(0o755) - def do_run(self, command: str) -> None: + def do_run(self, *, command: str, condition: str = 'true') -> None: """Run a command.""" + if not evaluate_condition(condition): + return + ui.info_2("Running", "`{}`".format(command)) subprocess.run(command, check=True, shell=True) self.base_dir.chdir() @@ -210,7 +213,7 @@ class Installer: def evaluate_condition(command: str) -> bool: """Run a bash command. On success return True, else return False.""" - return subprocess.run(command, shell=True).returncode == 0 + return subprocess.run(command, check=False, shell=True).returncode == 0 def main() -> None: