From 98fa9c168a86e4bff720bece964fe7a0fd1c259a Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 24 Jul 2017 13:09:23 +1000 Subject: [PATCH] tools: ratbagd: throw an error if the system bus is unavailable When running in a container (CircleCI), dbus may not be available. Throw one of our errors to be consistent with our behavior when the name owner isn't available. Signed-off-by: Peter Hutterer --- tools/ratbagd.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/ratbagd.py b/tools/ratbagd.py index cf160f12..6fedddc6 100644 --- a/tools/ratbagd.py +++ b/tools/ratbagd.py @@ -111,7 +111,11 @@ class _RatbagdDBus(GObject.GObject): GObject.GObject.__init__(self) if _RatbagdDBus._dbus is None: - _RatbagdDBus._dbus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None) + try: + _RatbagdDBus._dbus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None) + except GLib.Error: + raise RatbagdDBusUnavailable() + if _RatbagdDBus._dbus is None: raise RatbagdDBusUnavailable()