Fix add_python_path, ensure service exist before trying to log

This commit is contained in:
Marco Pesenti Gritti 2006-08-13 01:31:24 +02:00
parent c7c71d25a8
commit dd7fff79f8
2 changed files with 18 additions and 1 deletions

View File

@ -12,7 +12,8 @@ import sugar.setup
def add_to_python_path(path): def add_to_python_path(path):
sys.path.insert(0, path) sys.path.insert(0, path)
if os.environ.has_key('PYTHONPATH'): if os.environ.has_key('PYTHONPATH'):
os.environ['PYTHONPATH'] += ':' + path old_path = os.environ['PYTHONPATH']
os.environ['PYTHONPATH'] = path + ':' + old_path
else: else:
os.environ['PYTHONPATH'] = path os.environ['PYTHONPATH'] = path

View File

@ -16,11 +16,27 @@ class Handler(logging.Handler):
self._console_id = console_id self._console_id = console_id
self._console = console self._console = console
self._records = [] 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): def _log(self):
if not self._console_started:
return True
for record in self._records: for record in self._records:
self._console.log(record.levelno, self._console_id, record.msg) self._console.log(record.levelno, self._console_id, record.msg)
self._records = [] self._records = []
return False return False
def emit(self, record): def emit(self, record):