diff options
-rwxr-xr-x | src/service-discovery-applet.in | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/service-discovery-applet.in b/src/service-discovery-applet.in index d7de7ab..65da2b0 100755 --- a/src/service-discovery-applet.in +++ b/src/service-discovery-applet.in @@ -18,6 +18,8 @@ import subprocess import sys import pygtk +import pprint + import sdapplet.pluginloader import sdapplet.pluginutils @@ -135,9 +137,15 @@ class SDAGconf: # class Notifications: def __init__(self, applet): - self.session_bus = dbus.SessionBus() - obj = self.session_bus.get_object("org.freedesktop.Notifications", "/org/freedesktop/Notifications") - self.notif = dbus.Interface(obj, "org.freedesktop.Notifications") + try: + self.session_bus = dbus.SessionBus() + obj = self.session_bus.get_object("org.freedesktop.Notifications", "/org/freedesktop/Notifications") + self.notif = dbus.Interface(obj, "org.freedesktop.Notifications") + except dbus.DBusException, e: + error_msg(_("<b>DBus Error:</b>\nCan't contact the session bus.\n\nNotifications won't work!")) + self.applet.show_notifications = False + pprint.pprint(e) + pass self.applet = applet @@ -165,7 +173,7 @@ class Notifications: [], [], dbus.Int32(3000), dbus.UInt32(0)) except: print "can't use notification daemon" - pass + pass ############################################################################### @@ -224,12 +232,17 @@ class ServiceDiscoveryApplet(gnomeapplet.Applet): self.popup_control = applet.get_control() #Start Service Discovery self.domain = "" - self.system_bus = dbus.SystemBus() - self.server = dbus.Interface(self.system_bus.get_object(avahi.DBUS_NAME, avahi.DBUS_PATH_SERVER), - avahi.DBUS_INTERFACE_SERVER) + try: + self.system_bus = dbus.SystemBus() + self.server = dbus.Interface(self.system_bus.get_object(avahi.DBUS_NAME, avahi.DBUS_PATH_SERVER), + avahi.DBUS_INTERFACE_SERVER) - self.system_bus.add_signal_receiver(self.avahi_dbus_connect_cb, "NameOwnerChanged", "org.freedesktop.DBus", arg0="org.freedesktop.Avahi") - + self.system_bus.add_signal_receiver(self.avahi_dbus_connect_cb, "NameOwnerChanged", "org.freedesktop.DBus", arg0="org.freedesktop.Avahi") + except dbus.DBusException, e: + error_msg(_("<b>DBus Error:</b>\nCan't contact the system bus.\n\n Exiting...")) + pprint.pprint(e) + sys.exit(1) + try: self.use_host_names = self.server.IsNSSSupportAvailable() except: |