changeset 229:ab523cc967bb

core(notification): display a warning and disable notifications if something is going wrong
author Goffi <goffi@goffi.org>
date Mon, 02 Jul 2018 08:22:11 +0200
parents e702228b655a
children f95d0c31d455
files cagou/core/cagou_main.py
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/cagou/core/cagou_main.py	Fri Jun 29 16:14:09 2018 +0200
+++ b/cagou/core/cagou_main.py	Mon Jul 02 08:22:11 2018 +0200
@@ -818,8 +818,14 @@
 
     def desktop_notif(self, message, title=u'', duration=5000):
         if notification is not None:
-            notification.notify(title=title,
-                                message=message,
-                                app_name=C.APP_NAME,
-                                app_icon=self.app.icon,
-                                timeout = duration)
+            try:
+                notification.notify(title=title,
+                                    message=message,
+                                    app_name=C.APP_NAME,
+                                    app_icon=self.app.icon,
+                                    timeout = duration)
+            except Exception as e:
+                log.warning(_(u"Can't use notifications, disabling: {msg}").format(
+                    msg = e))
+                global notification
+                notification = None