Skip to content

Commit

Permalink
Don't crash when the notification service is not available
Browse files Browse the repository at this point in the history
It is possible that the notification service become unavailable during the
build, typically caused by the gnome-shell crash. It is better to lose the
notification than to crash jhbuild.

https://bugzilla.gnome.org/show_bug.cgi?id=748440
  • Loading branch information
lantw44 committed Jun 14, 2015
1 parent 248cd69 commit 77c053c
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions jhbuild/utils/notify.py
Expand Up @@ -43,18 +43,28 @@ def get_iface(self):
except dbus.exceptions.DBusException:
return None

def reset(self):
self.notif_id = 0
self.iface = self.get_iface()

def notify(self, summary, body, icon = "", expire = 0):
'''emit a notification'''
if self.disabled:
return

self.notif_id = self.iface.Notify("jhbuild", self.notif_id, icon,
summary, body, [], {}, 1000*expire)
try:
self.notif_id = self.iface.Notify("jhbuild", self.notif_id, icon,
summary, body, [], {}, 1000*expire)
except dbus.exceptions.DBusException:
self.reset()

def clear(self):
if self.notif_id != 0:
self.iface.CloseNotification(self.notif_id)
self.notif_id = 0
try:
self.iface.CloseNotification(self.notif_id)
self.notif_id = 0
except dbus.exceptions.DBusException:
self.reset()

if __name__ == "__main__":
n = Notify()
Expand Down

0 comments on commit 77c053c

Please sign in to comment.