From 0ff4ef4cab696b9e4ac2bef4c7f5a8fe7bbcc175 Mon Sep 17 00:00:00 2001 From: Joseph Hall Date: Tue, 15 Nov 2016 13:20:19 -0700 Subject: [PATCH] Properly gate dbus definitions --- salt/beacons/avahi_announce.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/salt/beacons/avahi_announce.py b/salt/beacons/avahi_announce.py index c5a34b2b21..4eb580be95 100644 --- a/salt/beacons/avahi_announce.py +++ b/salt/beacons/avahi_announce.py @@ -25,20 +25,23 @@ except ImportError: try: import dbus + from dbus import DBusException + BUS = dbus.SystemBus() + SERVER = dbus.Interface(BUS.get_object(avahi.DBUS_NAME, avahi.DBUS_PATH_SERVER), + avahi.DBUS_INTERFACE_SERVER) + GROUP = dbus.Interface(BUS.get_object(avahi.DBUS_NAME, SERVER.EntryGroupNew()), + avahi.DBUS_INTERFACE_ENTRY_GROUP) HAS_DBUS = True except ImportError: HAS_DBUS = False +except DBusException: + HAS_DBUS = False log = logging.getLogger(__name__) __virtualname__ = 'avahi_announce' LAST_GRAINS = {} -BUS = dbus.SystemBus() -SERVER = dbus.Interface(BUS.get_object(avahi.DBUS_NAME, avahi.DBUS_PATH_SERVER), - avahi.DBUS_INTERFACE_SERVER) -GROUP = dbus.Interface(BUS.get_object(avahi.DBUS_NAME, SERVER.EntryGroupNew()), - avahi.DBUS_INTERFACE_ENTRY_GROUP) def __virtual__():