From 59ad411b2f04ff9916bc84d3cd207550465f7c03 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Thu, 12 Dec 2019 07:26:55 +0100 Subject: [PATCH] [modules/datetimetz] Add logging --- bumblebee/modules/datetimetz.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bumblebee/modules/datetimetz.py b/bumblebee/modules/datetimetz.py index 1d0e3cb..c778be9 100644 --- a/bumblebee/modules/datetimetz.py +++ b/bumblebee/modules/datetimetz.py @@ -17,6 +17,7 @@ Parameters: from __future__ import absolute_import import datetime import locale +import logging try: import pytz import tzlocal @@ -41,10 +42,15 @@ class Module(bumblebee.engine.Module): engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE, cmd=self.next_tz) engine.input.register_callback(self, button=bumblebee.input.RIGHT_MOUSE, cmd=self.prev_tz) self._fmt = self.parameter("format", default_format(self.name)) + default_timezone = "" try: - self._timezones = self.parameter("timezone", tzlocal.get_localzone().zone).split(",") + default_timezone = tzlocal.get_localzone().zone + except Exception as e: + logging.error('unable to get default timezone: {}'.format(str(e))) + try: + self._timezones = self.parameter("timezone", default_timezone).split(",") except: - self._timezones = "" + self._timezones = [default_timezone] self._current_tz = 0 l = locale.getdefaultlocale() @@ -63,7 +69,8 @@ class Module(bumblebee.engine.Module): retval = datetime.datetime.now(tz=tzlocal.get_localzone()).astimezone(tz).strftime(self._fmt) except pytz.exceptions.UnknownTimeZoneError: retval = "[Unknown timezone: {}]".format(self._timezones[self._current_tz].strip()) - except: + except Exception as e: + logging.error('unable to get time: {}'.format(str(e))) retval = "[n/a]" enc = locale.getpreferredencoding()