aboutsummaryrefslogtreecommitdiff
path: root/gn3/commands.py
diff options
context:
space:
mode:
Diffstat (limited to 'gn3/commands.py')
-rw-r--r--gn3/commands.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/gn3/commands.py b/gn3/commands.py
index 459ccee..0f526d8 100644
--- a/gn3/commands.py
+++ b/gn3/commands.py
@@ -74,10 +74,11 @@ Returns the name of the specific redis hash for the specific task.
return unique_id
-def run_cmd(cmd: str) -> Dict:
+def run_cmd(cmd: str, success_codes: List = [0]) -> Dict:
"""Run CMD and return the CMD's status code and output as a dict"""
- results = subprocess.run(cmd, capture_output=True, shell=True, check=False)
+ results = subprocess.run(cmd, capture_output=True, shell=True,
+ check=False)
out = str(results.stdout, 'utf-8')
- if results.returncode < 0: # Error!
+ if results.returncode not in success_codes: # Error!
out = str(results.stderr, 'utf-8')
return {"code": results.returncode, "output": out}