[tracker/sam/tracker-sandbox-shared: 2/3] utils/trackertestutils: Give better error if dbus-daemon can't be found



commit 763d4f05f11c0b51105c44fc833d043fd1c86520
Author: Sam Thursfield <sam afuera me uk>
Date:   Sat Sep 28 14:42:45 2019 +0200

    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(-)
---
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:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]