Update error handling in data processing script

This commit is contained in:
Matt Tancik committed 2022-09-14 08:59:22 -07:00
1 parent 587e641884
commit 65ab15b5ce
1 file changed
+4 -1
+4 -1
View File
@@ -78,9 +78,12 @@ def run_command(cmd, verbose=False) -> Optional[str]:
Returns:
The output of the command if return_output is True, otherwise None.
"""
out = subprocess.run(cmd, capture_output=not verbose, shell=True, check=True)
out = subprocess.run(cmd, capture_output=not verbose, shell=True, check=False)
if out.returncode != 0:
CONSOLE.rule("[bold red] :skull: :skull: :skull: ERROR :skull: :skull: :skull: ", style="red")
CONSOLE.print(f"[bold red]Error running command: {cmd}")
CONSOLE.rule(style="red")
CONSOLE.print(out.stderr.decode("utf-8"))
sys.exit(1)
if out.stdout is not None:
return out.stdout.decode("utf-8")