Catch errors when connection to dbus

This commit is contained in:
Cole Robinson 2010-01-25 09:31:33 -05:00
parent f2405a6aba
commit afecfd9163
2 changed files with 5 additions and 4 deletions

View File

@ -84,14 +84,15 @@ class vmmConnect(gobject.GObject):
self.window.get_widget("conn-list").get_selection().connect("changed", self.conn_selected)
self.bus = dbus.SystemBus()
self.bus = None
self.server = None
self.can_browse = False
try:
self.bus = dbus.SystemBus()
self.server = dbus.Interface(self.bus.get_object("org.freedesktop.Avahi", "/"), "org.freedesktop.Avahi.Server")
self.can_browse = True
except Exception, e:
logging.debug("Couldn't contact avahi: %s" % str(e))
self.server = None
self.can_browse = False
self.reset_state()

View File

@ -773,9 +773,9 @@ class vmmConnection(gobject.GObject):
logging.debug("Skipping policykit check as root")
return 0
logging.debug("Doing policykit for %s" % action)
bus = dbus.SessionBus()
try:
bus = dbus.SessionBus()
# First try to use org.freedesktop.PolicyKit.AuthenticationAgent
# which is introduced with PolicyKit-0.7
obj = bus.get_object("org.freedesktop.PolicyKit.AuthenticationAgent", "/")