diff --git a/sugar/logger.py b/sugar/logger.py index 7f9dab1f..e5bc37cf 100644 --- a/sugar/logger.py +++ b/sugar/logger.py @@ -20,21 +20,21 @@ class MessageQueue: self._console_id = console_id self._levels = [] self._messages = [] - + self._bus = dbus.SessionBus() + if self._console == None: - bus = dbus.SessionBus() - con = bus._connection + con = self._bus._connection if dbus.dbus_bindings.bus_name_has_owner(con, CONSOLE_BUS_NAME): - print >> sys.stderr, 'Setup now' self.setup_console() else: - bus.add_signal_receiver(self.__name_owner_changed, - dbus_interface = "org.freedesktop.DBus", - signal_name = "NameOwnerChanged") + self._bus.add_signal_receiver( + self.__name_owner_changed, + dbus_interface = "org.freedesktop.DBus", + signal_name = "NameOwnerChanged") def setup_console(self): - bus = dbus.SessionBus() - proxy_obj = bus.get_object(CONSOLE_BUS_NAME, CONSOLE_OBJECT_PATH) + proxy_obj = self._bus.get_object(CONSOLE_BUS_NAME, + CONSOLE_OBJECT_PATH) self._console = dbus.Interface(proxy_obj, CONSOLE_IFACE) self._queue_log()