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 <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer
2017-07-24 13:09:23 +10:00
committed by Benjamin Tissoires
parent 0e26b6e2be
commit 98fa9c168a

View File

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