diff options
author | Sam Thursfield <sam@afuera.me.uk> | 2020-04-29 01:23:41 +0200 |
---|---|---|
committer | Sam Thursfield <sam@afuera.me.uk> | 2020-05-02 01:22:23 +0200 |
commit | 68fe90a7b8d0d6b5c3d6f2237e4ddfc8123f7e5a (patch) | |
tree | 80b0352cfdd57fc4d63256ff4f301f6b31654764 /utils | |
parent | 9f10204fc5bbe7518deb37dacbca42a962dd0905 (diff) | |
download | tracker-68fe90a7b8d0d6b5c3d6f2237e4ddfc8123f7e5a.tar.gz |
trackertestutils: Fix some issues with D-Bus name changes
The stop_miner_fs() function is now stop_daemon() and the caller
supplies the busname. This makes it more flexible and avoids hardcoding
the miner-fs busname.
Diffstat (limited to 'utils')
-rw-r--r-- | utils/trackertestutils/helpers.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/utils/trackertestutils/helpers.py b/utils/trackertestutils/helpers.py index a8f695665..afcee7e35 100644 --- a/utils/trackertestutils/helpers.py +++ b/utils/trackertestutils/helpers.py @@ -38,6 +38,10 @@ from . import psutil_mini as psutil log = logging.getLogger(__name__) +TRACKER_DBUS_PREFIX = 'org.freedesktop.Tracker3' +TRACKER_MINER_FS_BUSNAME = 'org.freedesktop.Tracker3.Miner.Files' + + class AwaitException(RuntimeError): pass @@ -489,7 +493,7 @@ class TrackerDBusSandbox: log.info("Looking for active Tracker processes on the bus") for busname in self.daemon.list_names_sync(): - if busname.startswith('org.freedesktop.Tracker3'): + if busname.startswith(TRACKER_DBUS_PREFIX): pid = self.daemon.get_connection_unix_process_id_sync(busname) if pid is not None: tracker_processes.append(pid) @@ -511,14 +515,21 @@ class TrackerDBusSandbox: log.info("Stopping D-Bus daemon for sandbox.") self.daemon.stop() - def stop_miner_fs(self): - log.info("Stopping tracker-miner-fs process.") - pid = self.daemon.get_connection_unix_process_id_sync('org.freedesktop.Tracker1.Miner.Files') + def stop_daemon(self, busname): + """Stops the daemon that owns 'busname'. + + This can be used if you want to force the miner-fs to exit, for + example. + + """ + log.info("Stopping daemon process that owns %s.", busname) + pid = self.daemon.get_connection_unix_process_id_sync(busname) if pid: os.kill(pid, signal.SIGTERM) psutil.wait_pid(pid) + log.info("Process %i has stopped.", pid) else: - log.info("tracker-miner-fs process was not found on the message bus.") + log.info("Couldn't find a process owning %s.", busname) def get_connection(self): return self.daemon.get_connection() |