mirror of
https://github.com/clearml/clearml-agent
synced 2025-06-03 11:16:19 +00:00
Support raise_error
in get_bash_output()
This commit is contained in:
parent
57cde21c48
commit
53d379205f
@ -25,7 +25,7 @@ from clearml_agent.helper.base import bash_c, is_windows_platform, select_for_pl
|
|||||||
PathLike = Union[Text, Path]
|
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:
|
try:
|
||||||
output = (
|
output = (
|
||||||
subprocess.check_output(
|
subprocess.check_output(
|
||||||
@ -37,6 +37,8 @@ def get_bash_output(cmd, strip=False, stderr=subprocess.STDOUT, stdin=False):
|
|||||||
.strip()
|
.strip()
|
||||||
)
|
)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
|
if raise_error:
|
||||||
|
raise
|
||||||
output = None
|
output = None
|
||||||
return output if not strip or not output else output.strip()
|
return output if not strip or not output else output.strip()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user