1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2025-07-09 00:00:54 +00:00

Add disabled code to log failed commands to stderr

This commit is contained in:
Joshua Tauberer 2024-07-28 13:43:04 -04:00
parent 3bfd4be982
commit 061e74b623

View File

@ -122,15 +122,18 @@ def shell(method, cmd_args, env=None, capture_stderr=False, return_bytes=False,
if method == "check_output" and input is not None: if method == "check_output" and input is not None:
kwargs['input'] = input kwargs['input'] = input
if not trap: try:
ret = getattr(subprocess, method)(cmd_args, **kwargs) ret = getattr(subprocess, method)(cmd_args, **kwargs)
else: code = 0
try: except subprocess.CalledProcessError as e:
ret = getattr(subprocess, method)(cmd_args, **kwargs) if not trap:
code = 0 if False:
except subprocess.CalledProcessError as e: import sys, shlex
ret = e.output print(shlex.join(cmd_args), file=sys.stderr)
code = e.returncode raise
raise
ret = e.output
code = e.returncode
if not return_bytes and isinstance(ret, bytes): ret = ret.decode("utf8") if not return_bytes and isinstance(ret, bytes): ret = ret.decode("utf8")
if not trap: if not trap:
return ret return ret