mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 11:18:08 -06:00
Handle properly a psutil exception. Closes #501
This commit is contained in:
parent
a3bc684721
commit
3adc726f33
13
src/main.py
13
src/main.py
@ -115,12 +115,13 @@ def check_pid():
|
||||
if os.path.exists(pidpath):
|
||||
with open(pidpath) as fin:
|
||||
pid = int(fin.read())
|
||||
p = psutil.Process(pid=pid)
|
||||
if p.is_running():
|
||||
# Display warning dialog
|
||||
commonMessageDialogs.common_error(_("{0} is already running. Close the other instance before starting this one. If you're sure that {0} isn't running, try deleting the file at {1}. If you're unsure of how to do this, contact the {0} developers.").format(application.name, pidpath))
|
||||
sys.exit(1)
|
||||
else:
|
||||
try:
|
||||
p = psutil.Process(pid=pid)
|
||||
if p.is_running():
|
||||
# Display warning dialog
|
||||
commonMessageDialogs.common_error(_("{0} is already running. Close the other instance before starting this one. If you're sure that {0} isn't running, try deleting the file at {1}. If you're unsure of how to do this, contact the {0} developers.").format(application.name, pidpath))
|
||||
sys.exit(1)
|
||||
except psutil.NoSuchProcess:
|
||||
commonMessageDialogs.dead_pid()
|
||||
# Write the new PID
|
||||
with open(pidpath,"w") as cam:
|
||||
|
Loading…
Reference in New Issue
Block a user