From 976e7234ae017018714d7548a84977d8968673ac Mon Sep 17 00:00:00 2001 From: pux Date: Sun, 24 May 2020 11:09:26 +0200 Subject: fix div/0 with -s 1 -m 0 and ignore dbus max notifications exceeded exception --- timebomb.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/timebomb.py b/timebomb.py index c8679bb..695f11a 100644 --- a/timebomb.py +++ b/timebomb.py @@ -23,7 +23,13 @@ def message(m, s): msg = 'ALARM, Timer ran ' + str(m) + 'm and ' + str(s) + ' s' notify_msg = notify2.Notification('ALARM', msg) - notify_msg.show() + try: + notify_msg.show() + except: + # ignore + # dbus.exceptions.DBusException: org.freedesktop.Notifications.Max + # NotificationsExceeded: Exceeded maximum number of notifications + pass if screen_width <= 0: screen_width = 1024 @@ -88,7 +94,11 @@ def sleep(m, s): if pbar_len < 20: pbar_len = 20 - progress = int(x/(time_sum_s-1) * pbar_len) + n = time_sum_s-1 + if n == 0: + progress = pbar_len + else: + progress = int(x/n * pbar_len) print(left, end='') print('#' * progress + '_' * int(pbar_len-progress), end='') -- cgit v1.2.2-1-g5e49