From aa3590a639ace10e2808e8b3a9f6a054a60e5139 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Wed, 17 Mar 2021 14:19:29 +0200 Subject: don't allow subprocess.run to fail --- ick_helpers.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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): -- cgit v1.2.1