From 53d379205fa942ac41bb2ed2b3db193e592addd0 Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Mon, 5 Dec 2022 11:26:40 +0200 Subject: [PATCH] Support `raise_error` in `get_bash_output()` --- clearml_agent/helper/process.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clearml_agent/helper/process.py b/clearml_agent/helper/process.py index 0029bb1..1494e4b 100644 --- a/clearml_agent/helper/process.py +++ b/clearml_agent/helper/process.py @@ -25,7 +25,7 @@ from clearml_agent.helper.base import bash_c, is_windows_platform, select_for_pl PathLike = Union[Text, Path] -def get_bash_output(cmd, strip=False, stderr=subprocess.STDOUT, stdin=False): +def get_bash_output(cmd, strip=False, stderr=subprocess.STDOUT, stdin=False, raise_error=False): try: output = ( subprocess.check_output( @@ -37,6 +37,8 @@ def get_bash_output(cmd, strip=False, stderr=subprocess.STDOUT, stdin=False): .strip() ) except subprocess.CalledProcessError: + if raise_error: + raise output = None return output if not strip or not output else output.strip()