Re-arrange startup to not use DBus activation in normal case (partial fix for bz 211636)
This commit is contained in:
parent
86399e34d7
commit
cc41177fa5
|
@ -102,7 +102,7 @@ from virtManager.remote import vmmRemote
|
|||
|
||||
gtk.window_set_default_icon_from_file(icon_dir + "/" + appname + "-icon.svg")
|
||||
|
||||
# maps --show-* to engine methods
|
||||
# maps --show-* to engine (ie local instance) methods
|
||||
def show_engine(engine, show, uri, uuid):
|
||||
if show=='creator':
|
||||
engine.show_create(uri)
|
||||
|
@ -117,7 +117,7 @@ def show_engine(engine, show, uri, uuid):
|
|||
else:
|
||||
engine.show_connect()
|
||||
|
||||
# maps --show-* to remote manager methods
|
||||
# maps --show-* to remote manager (ie dbus call) methods
|
||||
def show_remote(managerObj, show, uri, uuid):
|
||||
if show=='creator':
|
||||
managerObj.show_domain_creator(uri)
|
||||
|
@ -168,23 +168,19 @@ def main():
|
|||
|
||||
config = vmmConfig(appname, appversion, gconf_dir, glade_dir, icon_dir)
|
||||
engine = vmmEngine(config)
|
||||
if options.nodbus:
|
||||
show_engine(engine, options.show, options.uri, options.uuid)
|
||||
else:
|
||||
bus = None
|
||||
if not(options.nodbus) and not( (os.getenv("DBUS_SESSION_BUS_ADDRESS") is None ) and ( os.getenv("DBUS_STARTER_ADDRESS") is None ) ):
|
||||
try:
|
||||
if os.getenv("DBUS_STARTER_ADDRESS") == None and os.getenv("DBUS_SESSION_BUS_ADDRESS") == None:
|
||||
raise RuntimeError, "DBus session/starter bus address not defined"
|
||||
bus = dbus.SessionBus()
|
||||
bus = None
|
||||
if os.getenv("DBUS_STARTER_ADDRESS") is None:
|
||||
bus = dbus.SessionBus()
|
||||
else:
|
||||
bus = dbus.StarterBus()
|
||||
|
||||
dbusProxy = bus.get_object("org.freedesktop.DBus", "/org/freedesktop/DBus")
|
||||
dbusObj = dbus.Interface(dbusProxy, "org.freedesktop.DBus")
|
||||
|
||||
# If we're already running, then just talk to existing process
|
||||
if os.getenv("DBUS_STARTER_ADDRESS"):
|
||||
name = dbus.service.BusName("com.redhat.virt.manager", bus=bus)
|
||||
remote = vmmRemote(engine, name)
|
||||
else:
|
||||
if dbusObj.NameHasOwner("com.redhat.virt.manager"):
|
||||
# We're already running, so just talk to existing process
|
||||
managerProxy = bus.get_object("com.redhat.virt.manager", "/com/redhat/virt/manager")
|
||||
managerObj = dbus.Interface(managerProxy, "com.redhat.virt.manager")
|
||||
|
||||
|
@ -192,10 +188,17 @@ def main():
|
|||
|
||||
# yes, we exit completely now - remote service is in charge
|
||||
return
|
||||
else:
|
||||
# Grab the service to allow others to talk to us later
|
||||
name = dbus.service.BusName("com.redhat.virt.manager", bus=bus)
|
||||
remote = vmmRemote(engine, name)
|
||||
except:
|
||||
# Something went wrong doing dbus setup, just ignor & carry on
|
||||
logging.warning("Could not connection to session bus, disabling DBus service " + \
|
||||
str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]))
|
||||
show_engine(engine, options.show, options.uri, options.uuid)
|
||||
|
||||
# Finally start the app for real
|
||||
show_engine(engine, options.show, options.uri, options.uuid)
|
||||
gtk.main()
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in New Issue