aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test/py/lib
diff options
context:
space:
mode:
Diffstat (limited to 'test/py/lib')
-rw-r--r--test/py/lib/process.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/py/lib/process.py b/test/py/lib/process.py
index 3436280..d478c32 100644
--- a/test/py/lib/process.py
+++ b/test/py/lib/process.py
@@ -89,6 +89,9 @@ class CmdLine:
def run(self, *argv):
return Process.run(*self.argv, *argv)
+ def try_run(self, *argv):
+ return Process.try_run(*self.argv, *argv)
+
@contextmanager
def run_async(self, *argv):
with Process(self, *argv) as process:
@@ -146,6 +149,13 @@ class Process(subprocess.Popen):
Process._log_process_end(argv, ec, output)
raise
+ @staticmethod
+ def try_run(*args, **kwargs):
+ try:
+ return 0, Process.run(*args, **kwargs)
+ except subprocess.CalledProcessError as e:
+ return e.returncode, e.stdout
+
def __init__(self, cmd_line, *args):
self.cmd_line = cmd_line