comparison src/bridge/bridge_constructor/dbus_frontend_template.py @ 359:eb9d33ba4e36

bridge: templates' constants can now be overrided
author Goffi <goffi@goffi.org>
date Mon, 06 Jun 2011 18:35:30 +0200
parents 4402ac630712
children 141eeb7cd9e6
comparison
equal deleted inserted replaced
358:f147b778511a 359:eb9d33ba4e36
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 from logging import debug 24 from logging import debug
25 25
26 const_INT_PREFIX = "org.goffi.SAT" #Interface prefix
27 const_OBJ_PATH = '/org/goffi/SAT/bridge'
28 const_COMM_SUFFIX = ".communication"
29 const_REQ_SUFFIX = ".request"
30
26 class BridgeExceptionNoService(Exception): 31 class BridgeExceptionNoService(Exception):
27 pass 32 pass
28 33
29 class DBusBridgeFrontend(BridgeFrontend): 34 class DBusBridgeFrontend(BridgeFrontend):
30 def __init__(self): 35 def __init__(self):
31 try: 36 try:
32 self.sessions_bus = dbus.SessionBus() 37 self.sessions_bus = dbus.SessionBus()
33 self.db_object = self.sessions_bus.get_object('org.goffi.SAT', 38 self.db_object = self.sessions_bus.get_object(const_INT_PREFIX,
34 '/org/goffi/SAT/bridge') 39 const_OBJ_PATH)
35 self.db_comm_iface = dbus.Interface(self.db_object, 40 self.db_comm_iface = dbus.Interface(self.db_object,
36 dbus_interface='org.goffi.SAT.communication') 41 dbus_interface=const_INT_PREFIX + const_COMM_SUFFIX)
37 self.db_req_iface = dbus.Interface(self.db_object, 42 self.db_req_iface = dbus.Interface(self.db_object,
38 dbus_interface='org.goffi.SAT.request') 43 dbus_interface=const_INT_PREFIX + const_REQ_SUFFIX)
39 except dbus.exceptions.DBusException,e: 44 except dbus.exceptions.DBusException,e:
40 if e._dbus_error_name=='org.freedesktop.DBus.Error.ServiceUnknown': 45 if e._dbus_error_name=='org.freedesktop.DBus.Error.ServiceUnknown':
41 raise BridgeExceptionNoService 46 raise BridgeExceptionNoService
42 else: 47 else:
43 raise e 48 raise e