summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/gui/housekeeping.py
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2018-03-01 19:13:40 +0100
committerKali Kaneko <kali@leap.se>2018-03-01 19:43:09 +0100
commit2babe2e0ff4fd0caefe41cff946f9d625e6936c2 (patch)
tree6b8364e03b7d9b24b5edc2b9570f6b4e9e5e22b7 /src/leap/bitmask/gui/housekeeping.py
parentd7b00e6392112c8ceb01fb9ecae8866cfe166a71 (diff)
[bug] catch errors while cleaning up
Diffstat (limited to 'src/leap/bitmask/gui/housekeeping.py')
-rw-r--r--src/leap/bitmask/gui/housekeeping.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/leap/bitmask/gui/housekeeping.py b/src/leap/bitmask/gui/housekeeping.py
index b6c29b47..5d549619 100644
--- a/src/leap/bitmask/gui/housekeeping.py
+++ b/src/leap/bitmask/gui/housekeeping.py
@@ -49,16 +49,20 @@ def reset_authtoken():
def check_stale_pidfile():
def is_pid_running(pidno):
- return 1 == len(filter(lambda p: p.pid == int(pidno), psutil.process_iter()))
+ return 1 == len(
+ filter(lambda p: p.pid == int(pidno), psutil.process_iter()))
pidno = None
pidfile = os.path.join(get_path_prefix(), 'leap', 'bitmaskd.pid')
- if os.path.isfile(pidfile):
- with open(pidfile, 'r') as pid_fd:
- pidno = pid_fd.readline().strip()
- if pidno and pidno.isdigit():
- if not is_pid_running(pidno):
- os.unlink(pidfile)
+ try:
+ if os.path.isfile(pidfile):
+ with open(pidfile, 'r') as pid_fd:
+ pidno = pid_fd.readline().strip()
+ if pidno and pidno.isdigit():
+ if not is_pid_running(pidno):
+ os.unlink(pidfile)
+ except Exception as exc:
+ print('[bitmask] Error while removing stale file: %r' % exc)
def cleanup():
@@ -68,4 +72,7 @@ def cleanup():
pid = os.path.join(base, 'bitmaskd.pid')
for _f in [token, pid]:
if os.path.isfile(_f):
- os.unlink(_f)
+ try:
+ os.unlink(_f)
+ except Exception:
+ pass