mirror of https://github.com/zulip/zulip.git
zulip_tools: Improve error for `run` subprocess killed by signal.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
3e24a05e66
commit
f66136fcc2
|
@ -12,6 +12,7 @@ import random
|
||||||
import re
|
import re
|
||||||
import shlex
|
import shlex
|
||||||
import shutil
|
import shutil
|
||||||
|
import signal
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
@ -236,12 +237,25 @@ def run(args: Sequence[str], **kwargs: Any) -> None:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subprocess.check_call(args, **kwargs)
|
subprocess.check_call(args, **kwargs)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError as error:
|
||||||
print()
|
print()
|
||||||
print(
|
if error.returncode < 0:
|
||||||
WHITEONRED + f"Error running a subcommand of {sys.argv[0]}: {shlex.join(args)}" + ENDC
|
try:
|
||||||
)
|
signal_name = signal.Signals(-error.returncode).name
|
||||||
print(WHITEONRED + "Actual error output for the subcommand is just above this." + ENDC)
|
except ValueError:
|
||||||
|
signal_name = f"unknown signal {-error.returncode}"
|
||||||
|
print(
|
||||||
|
WHITEONRED
|
||||||
|
+ f"Subcommand of {sys.argv[0]} died with {signal_name}: {shlex.join(args)}"
|
||||||
|
+ ENDC
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
print(
|
||||||
|
WHITEONRED
|
||||||
|
+ f"Subcommand of {sys.argv[0]} failed with exit status {error.returncode}: {shlex.join(args)}"
|
||||||
|
+ ENDC
|
||||||
|
)
|
||||||
|
print(WHITEONRED + "Actual error output for the subcommand is just above this." + ENDC)
|
||||||
print()
|
print()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue