Qix- / better-exceptions

Pretty and useful exceptions in Python, automatically.
MIT License
4.59k stars 202 forks source link

Only run `ps -ww -p $PID -o command=` if ps executable is available #107

Closed sumanthratna closed 3 years ago

sumanthratna commented 3 years ago

currently, this is what errors with better-exceptions look like when ps is not available:

Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/better_exceptions/formatter.py", line 161, in get_string_source
    cmdline = spawn(['ps', '-ww', '-p', str(os.getpid()), '-o', 'command='])
  File "/usr/local/lib/python3.8/subprocess.py", line 411, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/local/lib/python3.8/subprocess.py", line 489, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/local/lib/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/lib/python3.8/subprocess.py", line 1702, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ps'

Original exception was:
Traceback (most recent call last):
...
Qix- commented 3 years ago

In which situation is ps not available?

sumanthratna commented 3 years ago

In which situation is ps not available?

e.g., in a slim-buster Docker container

Qix- commented 3 years ago

Looks good, thank you. Ill try to publish within the next hour or so.

Qix- commented 3 years ago

@sumanthratna finally published, sorry. I was having tons of strange issues pushing to pypi after such a long time not working with it lol. Had to clear some obscure obsolete cache and finally got it uploaded as 0.2.3 - let me know if there are any issues.

sumanthratna commented 3 years ago

Thanks! Just tested out 0.2.3 and 0.3.0:

and thanks for publishing new versions so quickly :)