From dd7fff79f87116dd69d975187363da48edfbfa4b Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Sun, 13 Aug 2006 01:31:24 +0200 Subject: [PATCH] Fix add_python_path, ensure service exist before trying to log --- sugar/env.py | 3 ++- sugar/logger.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/sugar/env.py b/sugar/env.py index 2a29daa5..66299bfd 100644 --- a/sugar/env.py +++ b/sugar/env.py @@ -12,7 +12,8 @@ import sugar.setup def add_to_python_path(path): sys.path.insert(0, path) if os.environ.has_key('PYTHONPATH'): - os.environ['PYTHONPATH'] += ':' + path + old_path = os.environ['PYTHONPATH'] + os.environ['PYTHONPATH'] = path + ':' + old_path else: os.environ['PYTHONPATH'] = path diff --git a/sugar/logger.py b/sugar/logger.py index fd5bf312..8c4ecff8 100644 --- a/sugar/logger.py +++ b/sugar/logger.py @@ -16,11 +16,27 @@ class Handler(logging.Handler): self._console_id = console_id self._console = console self._records = [] + self._console_started = False + + bus = dbus.SessionBus() + bus.add_signal_receiver(self.__name_owner_changed, + dbus_interface = "org.freedesktop.DBus", + signal_name = "NameOwnerChanged") + + def __name_owner_changed(self, service_name, old_name, new_name): + if new_name != None: + self._console_started = True + else: + self._console_started = False def _log(self): + if not self._console_started: + return True + for record in self._records: self._console.log(record.levelno, self._console_id, record.msg) self._records = [] + return False def emit(self, record):