Mercurial > libervia-backend
comparison src/bridge/bridge_constructor/dbus_frontend_template.py @ 993:301b342c697a
core: use of the new core.log module:
/!\ this is a massive refactoring and was largely automated, it probably did bring some bugs /!\
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 19 Apr 2014 19:19:19 +0200 |
parents | 1fe00f0c9a91 |
children | 95758ef3faa8 |
comparison
equal
deleted
inserted
replaced
992:f51a1895275c | 993:301b342c697a |
---|---|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 |
20 from sat.core.i18n import _ | 20 from sat.core.i18n import _ |
21 from bridge_frontend import BridgeFrontend | 21 from bridge_frontend import BridgeFrontend |
22 import dbus | 22 import dbus |
23 from logging import debug, error | 23 from sat.core.log import getLogger |
24 log = getLogger(__name__) | |
24 from sat.core.exceptions import BridgeExceptionNoService, BridgeInitError | 25 from sat.core.exceptions import BridgeExceptionNoService, BridgeInitError |
25 | 26 |
26 from dbus.mainloop.glib import DBusGMainLoop | 27 from dbus.mainloop.glib import DBusGMainLoop |
27 DBusGMainLoop(set_as_default=True) | 28 DBusGMainLoop(set_as_default=True) |
28 | 29 |
45 dbus_interface=const_INT_PREFIX + const_PLUGIN_SUFFIX) | 46 dbus_interface=const_INT_PREFIX + const_PLUGIN_SUFFIX) |
46 except dbus.exceptions.DBusException, e: | 47 except dbus.exceptions.DBusException, e: |
47 if e._dbus_error_name == 'org.freedesktop.DBus.Error.ServiceUnknown': | 48 if e._dbus_error_name == 'org.freedesktop.DBus.Error.ServiceUnknown': |
48 raise BridgeExceptionNoService | 49 raise BridgeExceptionNoService |
49 elif e._dbus_error_name == 'org.freedesktop.DBus.Error.NotSupported': | 50 elif e._dbus_error_name == 'org.freedesktop.DBus.Error.NotSupported': |
50 print u"D-Bus is not launched, please see README to see instructions on how to launch it" | 51 log.error(_(u"D-Bus is not launched, please see README to see instructions on how to launch it")) |
51 raise BridgeInitError | 52 raise BridgeInitError |
52 else: | 53 else: |
53 raise e | 54 raise e |
54 #props = self.db_core_iface.getProperties() | 55 #props = self.db_core_iface.getProperties() |
55 | 56 |
57 if iface == "core": | 58 if iface == "core": |
58 self.db_core_iface.connect_to_signal(functionName, handler) | 59 self.db_core_iface.connect_to_signal(functionName, handler) |
59 elif iface == "plugin": | 60 elif iface == "plugin": |
60 self.db_plugin_iface.connect_to_signal(functionName, handler) | 61 self.db_plugin_iface.connect_to_signal(functionName, handler) |
61 else: | 62 else: |
62 error(_('Unknown interface')) | 63 log.error(_('Unknown interface')) |
63 | 64 |
64 def __getattribute__(self, name): | 65 def __getattribute__(self, name): |
65 """ usual __getattribute__ if the method exists, else try to find a plugin method """ | 66 """ usual __getattribute__ if the method exists, else try to find a plugin method """ |
66 try: | 67 try: |
67 return object.__getattribute__(self, name) | 68 return object.__getattribute__(self, name) |