From 1cfd208f7bc6873b5fe7b610835fb7201363542d Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Wed, 16 Aug 2006 00:30:50 +0200 Subject: [PATCH 1/4] Do not pass the timeout argument if we are using the in-process console --- shell/ConsoleWindow.py | 12 ++++++------ sugar/logger.py | 16 +++++++++++----- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/shell/ConsoleWindow.py b/shell/ConsoleWindow.py index 5efd880c..3c98bfe9 100644 --- a/shell/ConsoleWindow.py +++ b/shell/ConsoleWindow.py @@ -47,10 +47,7 @@ class ConsoleDbusService(dbus.service.Object): @dbus.service.method('org.laptop.Sugar.Console', in_signature="saias", out_signature="") def log(self, module_id, levels, messages): - i = 0 - while i < len(levels): - self._console.log(levels[i], module_id, messages[i]) - i += 1 + self._console.log(module_id, levels, messages) class ConsoleWindow(gtk.Window): def __init__(self): @@ -122,6 +119,9 @@ class ConsoleWindow(gtk.Window): page = self._nb.page_num(self._consoles[page_id]) self._nb.set_current_page(page) - def log(self, level, page_id, message): + def log(self, page_id, levels, messages): console = self._get_console(page_id) - console.log(level, message) + i = 0 + while i < len(levels): + console.log(levels[i], messages[i]) + i += 1 diff --git a/sugar/logger.py b/sugar/logger.py index 9328058a..7f9dab1f 100644 --- a/sugar/logger.py +++ b/sugar/logger.py @@ -25,10 +25,12 @@ class MessageQueue: bus = dbus.SessionBus() con = bus._connection if dbus.dbus_bindings.bus_name_has_owner(con, CONSOLE_BUS_NAME): + print >> sys.stderr, 'Setup now' self.setup_console() - bus.add_signal_receiver(self.__name_owner_changed, - dbus_interface = "org.freedesktop.DBus", - signal_name = "NameOwnerChanged") + else: + bus.add_signal_receiver(self.__name_owner_changed, + dbus_interface = "org.freedesktop.DBus", + signal_name = "NameOwnerChanged") def setup_console(self): bus = dbus.SessionBus() @@ -51,8 +53,12 @@ class MessageQueue: if self._console == None or len(self._messages) == 0: return False - self._console.log(self._console_id, self._levels, - self._messages, timeout = 1000) + if isinstance(self._console, dbus.Interface): + self._console.log(self._console_id, self._levels, + self._messages, timeout = 1000) + else: + self._console.log(self._console_id, self._levels, + self._messages) self._levels = [] self._messages = [] From 6b181ced1307e9e02d43735fd364befbcdfa972a Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Wed, 16 Aug 2006 00:41:51 +0200 Subject: [PATCH 2/4] Some cleanups --- sugar/logger.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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() From 2a50bbd3ca50e44b49c619b85ae1d697c75af7c4 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 16 Aug 2006 11:15:59 -0400 Subject: [PATCH 3/4] Fix service unregistration; the service will get cleaned up when Avahi notices that it has gone away so we don't have to delete it ourselves --- shell/PresenceService/PresenceService.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/shell/PresenceService/PresenceService.py b/shell/PresenceService/PresenceService.py index 3f655b9f..f062a830 100644 --- a/shell/PresenceService/PresenceService.py +++ b/shell/PresenceService/PresenceService.py @@ -661,8 +661,6 @@ class PresenceService(object): if not group: raise ValueError("Service was not a local service provided by this laptop!") group.Free() - key = (service.get_full_name(), service.get_type()) - del self._services[key] def register_service_type(self, stype): """Requests that the Presence service look for and recognize From 9ad1fe62aeb5b360a2c6f7e81149b5b0669ce67a Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 16 Aug 2006 12:09:43 -0400 Subject: [PATCH 4/4] Don't allow PS to be started twice --- shell/PresenceService/PresenceService.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/shell/PresenceService/PresenceService.py b/shell/PresenceService/PresenceService.py index f062a830..72e9460a 100644 --- a/shell/PresenceService/PresenceService.py +++ b/shell/PresenceService/PresenceService.py @@ -265,7 +265,13 @@ class PresenceService(object): self._bus_name = dbus.service.BusName(_PRESENCE_SERVICE, bus=self._session_bus) self._dbus_helper = PresenceServiceDBusHelper(self, self._bus_name) + self._started = False + def start(self): + if self._started: + return + self._started = True + # Connect to Avahi for mDNS stuff self._system_bus = dbus.SystemBus() self._mdns_service = dbus.Interface(self._system_bus.get_object(avahi.DBUS_NAME,