comparison frontends/sat_bridge_frontend/DBus.py @ 165:8a2053de6f8c

Frontends: management of unlaunched SàT Backend (information message and exit) DBus Bridge Frontend: added an exception to manage unlaunched SàT Backend (BridgeExceptionNoService) Quick App, jp: a message is print when the previous exception is launched
author Goffi <goffi@goffi.org>
date Mon, 09 Aug 2010 21:36:31 +0800
parents d6c0fe7489af
children 96af1bec2e68
comparison
equal deleted inserted replaced
164:5d7a011d78ba 165:8a2053de6f8c
20 """ 20 """
21 21
22 from bridge_frontend import BridgeFrontend 22 from bridge_frontend import BridgeFrontend
23 import dbus, dbus.glib 23 import dbus, dbus.glib
24 24
25 class BridgeExceptionNoService(Exception):
26 pass
25 27
26 class DBusBridgeFrontend(BridgeFrontend): 28 class DBusBridgeFrontend(BridgeFrontend):
27 def __init__(self): 29 def __init__(self):
28 self.sessions_bus = dbus.SessionBus() 30 try:
29 self.db_object = self.sessions_bus.get_object('org.goffi.SAT', 31 self.sessions_bus = dbus.SessionBus()
30 '/org/goffi/SAT/bridge') 32 self.db_object = self.sessions_bus.get_object('org.goffi.SAT',
31 self.db_comm_iface = dbus.Interface(self.db_object, 33 '/org/goffi/SAT/bridge')
32 dbus_interface='org.goffi.SAT.communication') 34 self.db_comm_iface = dbus.Interface(self.db_object,
33 self.db_req_iface = dbus.Interface(self.db_object, 35 dbus_interface='org.goffi.SAT.communication')
34 dbus_interface='org.goffi.SAT.request') 36 self.db_req_iface = dbus.Interface(self.db_object,
37 dbus_interface='org.goffi.SAT.request')
38 except dbus.exceptions.DBusException,e:
39 if e._dbus_error_name=='org.freedesktop.DBus.Error.ServiceUnknown':
40 raise BridgeExceptionNoService
41 else:
42 raise e
35 #props = self.db_comm_iface.getProperties() 43 #props = self.db_comm_iface.getProperties()
36 44
37 def register(self, functionName, handler, iface="communication"): 45 def register(self, functionName, handler, iface="communication"):
38 if iface == "communication": 46 if iface == "communication":
39 self.db_comm_iface.connect_to_signal(functionName, handler) 47 self.db_comm_iface.connect_to_signal(functionName, handler)