Mercurial > libervia-backend
comparison frontends/src/bridge/dbus_bridge.py @ 2091:f413bfc24458
bridge, quick_frontend: preparation for async bridge
bridge can currently have sync and async methods. This commit prepare the transition to fully async bridges:
- a new bridgeConnect method must be called to prepare the bridge
- quick app, quick profile manager: changed sync calls to async ones
- quick app: bridgeConnect can be called automatically or manually depending on connect_bridge parameter of QuickApp
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 13 Dec 2016 22:27:48 +0100 |
parents | 4633cfcbcccb |
children | 9c861d07b5b6 |
comparison
equal
deleted
inserted
replaced
2090:52bd463e6fe7 | 2091:f413bfc24458 |
---|---|
58 condition = '' | 58 condition = '' |
59 return BridgeException(name, message, condition) | 59 return BridgeException(name, message, condition) |
60 | 60 |
61 | 61 |
62 class Bridge(BridgeFrontend): | 62 class Bridge(BridgeFrontend): |
63 def __init__(self): | 63 |
64 def bridgeConnect(self, callback, errback): | |
64 try: | 65 try: |
65 self.sessions_bus = dbus.SessionBus() | 66 self.sessions_bus = dbus.SessionBus() |
66 self.db_object = self.sessions_bus.get_object(const_INT_PREFIX, | 67 self.db_object = self.sessions_bus.get_object(const_INT_PREFIX, |
67 const_OBJ_PATH) | 68 const_OBJ_PATH) |
68 self.db_core_iface = dbus.Interface(self.db_object, | 69 self.db_core_iface = dbus.Interface(self.db_object, |
70 self.db_plugin_iface = dbus.Interface(self.db_object, | 71 self.db_plugin_iface = dbus.Interface(self.db_object, |
71 dbus_interface=const_INT_PREFIX + const_PLUGIN_SUFFIX) | 72 dbus_interface=const_INT_PREFIX + const_PLUGIN_SUFFIX) |
72 except dbus.exceptions.DBusException, e: | 73 except dbus.exceptions.DBusException, e: |
73 if e._dbus_error_name in ('org.freedesktop.DBus.Error.ServiceUnknown', | 74 if e._dbus_error_name in ('org.freedesktop.DBus.Error.ServiceUnknown', |
74 'org.freedesktop.DBus.Error.Spawn.ExecFailed'): | 75 'org.freedesktop.DBus.Error.Spawn.ExecFailed'): |
75 raise BridgeExceptionNoService | 76 errback(BridgeExceptionNoService()) |
76 elif e._dbus_error_name == 'org.freedesktop.DBus.Error.NotSupported': | 77 elif e._dbus_error_name == 'org.freedesktop.DBus.Error.NotSupported': |
77 log.error(_(u"D-Bus is not launched, please see README to see instructions on how to launch it")) | 78 log.error(_(u"D-Bus is not launched, please see README to see instructions on how to launch it")) |
78 raise BridgeInitError | 79 errback(BridgeInitError) |
79 else: | 80 else: |
80 raise e | 81 errback(e) |
82 callback() | |
81 #props = self.db_core_iface.getProperties() | 83 #props = self.db_core_iface.getProperties() |
82 | 84 |
83 def register_signal(self, functionName, handler, iface="core"): | 85 def register_signal(self, functionName, handler, iface="core"): |
84 if iface == "core": | 86 if iface == "core": |
85 self.db_core_iface.connect_to_signal(functionName, handler) | 87 self.db_core_iface.connect_to_signal(functionName, handler) |