From 501c891a12cd4aeec3c3682f93532c391d09806c Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Wed, 31 Jan 2018 16:23:32 +0100 Subject: [PATCH] kete: bubble up the dbus vanished errors Not much is done for now, but the shell is notified, which is a big step --- tools/tuhi-kete.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/tuhi-kete.py b/tools/tuhi-kete.py index cbd5745..66b3331 100755 --- a/tools/tuhi-kete.py +++ b/tools/tuhi-kete.py @@ -231,6 +231,8 @@ class TuhiKeteManager(_DBusObject): __gsignals__ = { 'pairable-device': (GObject.SIGNAL_RUN_FIRST, None, (GObject.TYPE_PYOBJECT,)), + 'dbus-name-vanished': + (GObject.SIGNAL_RUN_FIRST, None, ()), } def __init__(self): @@ -320,8 +322,8 @@ class TuhiKeteManager(_DBusObject): def _on_name_vanished(self, connection, name): logger.error('Tuhi daemon went away') + self.emit('dbus-name-vanished') self.mainloop.quit() - # FIXME: need to bubble this up to the Worker def __getitem__(self, btaddr): return self._devices[btaddr] @@ -541,12 +543,16 @@ class TuhiKeteShell(cmd.Cmd): logger.addHandler(self._log_handler) # patching get_names to hide some functions we do not want in the help self.get_names = self._filtered_get_names + manager.connect('dbus-name-vanished', self._on_name_vanished) def _filtered_get_names(self): names = super(TuhiKeteShell, self).get_names() names.remove('do_EOF') return names + def _on_name_vanished(self, manager): + logger.debug('Tuhi daemon went away, I should stop the current workers') + def emptyline(self): # make sure we do not re-enter the last typed command pass