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,13 +122,16 @@ 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:
ret = getattr(subprocess, method)(cmd_args, **kwargs)
else:
try: try:
ret = getattr(subprocess, method)(cmd_args, **kwargs) ret = getattr(subprocess, method)(cmd_args, **kwargs)
code = 0 code = 0
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
if not trap:
if False:
import sys, shlex
print(shlex.join(cmd_args), file=sys.stderr)
raise
raise
ret = e.output ret = e.output
code = e.returncode 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")