diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-03-17 14:19:29 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-03-17 14:19:29 +0200 |
commit | aa3590a639ace10e2808e8b3a9f6a054a60e5139 (patch) | |
tree | acd6c272375d8d4d8b2e1823566716c7de01d259 | |
parent | bc4a2f824d4338a2a65d44b035ac163c0a209106 (diff) | |
download | ick-helpers-aa3590a639ace10e2808e8b3a9f6a054a60e5139.tar.gz |
don't allow subprocess.run to fail
-rw-r--r-- | ick_helpers.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/ick_helpers.py b/ick_helpers.py index cbef518..4290629 100644 --- a/ick_helpers.py +++ b/ick_helpers.py @@ -33,9 +33,12 @@ class Exec: def run(self, *args, **kwargs): # Run a command. + assert "check" in kwargs + check = kwargs.pop("check") + kwargs["check"] = False + if "cwd" not in kwargs: kwargs["cwd"] = self.dirname - assert "check" in kwargs kwargs["capture_output"] = True debug("RUN:", args, kwargs) @@ -44,6 +47,9 @@ class Exec: sys.stdout.write("STDOUT:\n%s" % x.stdout.decode("UTF-8")) if x.stderr: sys.stdout.write("STDERR:\n%s" % x.stderr.decode("UTF-8")) + sys.stdout.write("EXIT: %s\n" % x.returncde) + if check and x.returncode > 0: + raise Exception("command failed") return x def get_stdout(self, *args, **kwargs): |