Add condition to run command
This commit is contained in:
parent
9dc3b285fa
commit
7ace1385b4
1 changed files with 5 additions and 2 deletions
|
@ -89,9 +89,12 @@ class Installer:
|
||||||
if executable:
|
if executable:
|
||||||
p_dest.chmod(0o755)
|
p_dest.chmod(0o755)
|
||||||
|
|
||||||
def do_run(self, command: str) -> None:
|
def do_run(self, *, command: str, condition: str = 'true') -> None:
|
||||||
"""Run a command."""
|
"""Run a command."""
|
||||||
|
|
||||||
|
if not evaluate_condition(condition):
|
||||||
|
return
|
||||||
|
|
||||||
ui.info_2("Running", "`{}`".format(command))
|
ui.info_2("Running", "`{}`".format(command))
|
||||||
subprocess.run(command, check=True, shell=True)
|
subprocess.run(command, check=True, shell=True)
|
||||||
self.base_dir.chdir()
|
self.base_dir.chdir()
|
||||||
|
@ -210,7 +213,7 @@ class Installer:
|
||||||
def evaluate_condition(command: str) -> bool:
|
def evaluate_condition(command: str) -> bool:
|
||||||
"""Run a bash command. On success return True, else return False."""
|
"""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:
|
def main() -> None:
|
||||||
|
|
Loading…
Add table
Reference in a new issue