From 763d4f05f11c0b51105c44fc833d043fd1c86520 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Sat, 28 Sep 2019 14:42:45 +0200 Subject: utils/trackertestutils: Give better error if dbus-daemon can't be found We also now use `shutil.which()` to find the binary. This shouldn't change anything as we were already looking in PATH for the binary. --- utils/trackertestutils/dbusdaemon.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'utils') diff --git a/utils/trackertestutils/dbusdaemon.py b/utils/trackertestutils/dbusdaemon.py index 796fdc912..abd8c6b02 100644 --- a/utils/trackertestutils/dbusdaemon.py +++ b/utils/trackertestutils/dbusdaemon.py @@ -21,6 +21,7 @@ from gi.repository import GLib import logging import os +import shutil import signal import subprocess import threading @@ -58,8 +59,16 @@ class DBusDaemon: raise DaemonNotStartedError() return self._gdbus_connection + def _dbus_daemon_path(self): + dbus_daemon = shutil.which('dbus-daemon') + + if dbus_daemon is None: + raise RuntimeError("Could not find `dbus-daemon` binary in PATH (%s)." % os.environ.get('PATH')) + + return dbus_daemon + def start(self, config_file=None, env=None, new_session=False): - dbus_command = ['dbus-daemon', '--print-address=1', '--print-pid=1'] + dbus_command = [self._dbus_daemon_path(), '--print-address=1', '--print-pid=1'] if config_file: dbus_command += ['--config-file=' + config_file] else: -- cgit v1.2.1