From 590de682690a0b244b1c1511327f5e9377a753a3 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Tue, 13 Feb 2018 14:01:49 +0100 Subject: [PATCH] kete: make Searcher and Listener symmetrical regarding logs The 'searching' notification was only emitted when it goes to stop, which means we do not get notifications when it starts. This makes SearchStopped signal redundant for the generic case, but allows to get notifications if the search failed to start. Rest is just making sure we have the same handling of events in Listener and Searcher. --- tools/tuhi-kete.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/tuhi-kete.py b/tools/tuhi-kete.py index fe21942..e1a9cd1 100755 --- a/tools/tuhi-kete.py +++ b/tools/tuhi-kete.py @@ -346,6 +346,8 @@ class TuhiKeteManager(_DBusObject): # in unregistered devices pass self.notify('devices') + if 'Searching' in changed_props: + self.notify('searching') def _handle_unregistered_device(self, objpath): for addr, dev in self._devices.items(): @@ -418,8 +420,8 @@ class Searcher(Worker): logger.error('Another client is already searching') return + logger.debug(f'Starting searching') self.manager.start_search() - logger.debug('Started searching') def stop(self): if self.manager.searching: @@ -432,6 +434,8 @@ class Searcher(Worker): if not manager.searching: logger.info('Search cancelled') self.stop() + else: + logger.info('Search started') def _on_unregistered_device(self, manager, device): logger.info(f'Unregistered device: {device}') @@ -471,8 +475,9 @@ class Listener(Worker): self.device.start_listening() def stop(self): - logger.debug(f'{self.device}: stopping listening') - self.device.stop_listening() + if self.device.listening: + logger.debug(f'{self.device}: stopping listening') + self.device.stop_listening() self.cleanup()