Only run ps -ww -p $PID -o command= if available

This commit is contained in:
Sumanth Ratna 2020-12-20 17:26:32 -05:00 committed by Qix
parent 7b41752775
commit 249bc245b9

View File

@ -161,11 +161,16 @@ class ExceptionFormatter(object):
pass
if cmdline is None and os.name == 'posix':
from subprocess import CalledProcessError, check_output as spawn
from shutil import which
try:
cmdline = spawn(['ps', '-ww', '-p', str(os.getpid()), '-o', 'command='])
except CalledProcessError:
if which('ps'):
from subprocess import CalledProcessError, check_output as spawn
try:
cmdline = spawn(['ps', '-ww', '-p', str(os.getpid()), '-o', 'command='])
except CalledProcessError:
return ''
else:
return ''
else:
# current system doesn't have a way to get the command line