ofek / userpath

Cross-platform tool for adding locations to the user PATH, no elevated privileges required!
MIT License
151 stars 20 forks source link

Fix utils and get_parent_process_name(). #31

Closed itsayellow closed 3 years ago

itsayellow commented 3 years ago

Closes #30

I modified utils.py so that psutil does not raise a NameError in the case when psutil is not present. The original code of get_parent_process_name() would always raise an Exception in the past just from checking if psutil: if psutil was not successfully imported, and thus would always return the empty string "" without being able to fall back on executing the ps subprocess.

In addition, I used args= instead of cmd= in the ps command, because it is a synonym and is more universal. args= works on macOS (and presumably BSD) but cmd= does not.

I also removed a preceding - from the process name, in case the shell was called as a login shell.

ofek commented 3 years ago

https://pypi.org/project/userpath/1.4.2/