def setup_dbus_or_bring_other_instance_to_front(self, args):
"""
This sets up a dbus listener
"""
try:
bus = dbus.SessionBus()
except:
LOG.exception("could not initiate dbus")
return
# if there is another Softwarecenter running bring it to front
# and exit, otherwise install the dbus controller
try:
proxy_obj = bus.get_object('com.ubuntu.Softwarecenter',
'/com/ubuntu/Softwarecenter')
iface = dbus.Interface(proxy_obj, 'com.ubuntu.SoftwarecenterIFace')
if args:
res = iface.bringToFront(args)
else:
# None can not be transported over dbus
res = iface.bringToFront('nothing-to-show')
# ensure that the running s-c is working
if res is not True:
LOG.info("found a running software-center on dbus, "
"reconnecting")
sys.exit()
except dbus.DBusException:
bus_name = dbus.service.BusName('com.ubuntu.Softwarecenter', bus)
self.dbusControler = SoftwarecenterDbusController(self, bus_name)
评论列表
文章目录