Fix add_python_path, ensure service exist before trying to log
This commit is contained in:
parent
c7c71d25a8
commit
dd7fff79f8
@ -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
|
||||
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user