From 340725e9a7906e64b5852358b4bd7706f7207a67 Mon Sep 17 00:00:00 2001 From: David Paleino Date: Sun, 6 Feb 2011 18:54:57 +0100 Subject: [PATCH] Don't crash on notification errors This is not an essential feature, so no need to crash. --- gtk/wicd-client.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/gtk/wicd-client.py b/gtk/wicd-client.py index 52f67f6..d847d7a 100644 --- a/gtk/wicd-client.py +++ b/gtk/wicd-client.py @@ -227,15 +227,24 @@ class TrayIcon(object): def _show_notification(self, title, details, image=None): if self.should_notify: - if not self._last_bubble: - self._last_bubble = pynotify.Notification(title, details, - image) - self._last_bubble.show() - else: - self._last_bubble.clear_actions() - self._last_bubble.clear_hints() - self._last_bubble.update(title, details, image) - self._last_bubble.show() + try: + if not self._last_bubble: + self._last_bubble = pynotify.Notification(title, details, + image) + self._last_bubble.show() + else: + self._last_bubble.clear_actions() + self._last_bubble.clear_hints() + self._last_bubble.update(title, details, image) + self._last_bubble.show() + except Exception, e: + if hasattr(e, 'message') and e.message != '': + msg = e.message + elif hasattr(e, 'args') and len(e.args) > 0: + msg = e.args[-1] + else: + msg = str(e) + print "Exception during notification: %s" % msg self.should_notify = False