From dadca6a277f9853e9b7f8d20249a8d4f33af2af0 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Tue, 22 Nov 2016 15:14:04 +0100 Subject: Verify the presence of dbus python binding While the proper fix is to have it installed by default, this commit will also permit to have a better error message in the case the module is not present (as running on python 3) --- roles/openshift_facts/library/openshift_facts.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'roles/openshift_facts') diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index d797eb4d3..0d85dba4b 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -22,9 +22,14 @@ from distutils.util import strtobool from distutils.version import LooseVersion import struct import socket -from dbus import SystemBus, Interface -from dbus.exceptions import DBusException +HAVE_DBUS=False +try: + from dbus import SystemBus, Interface + from dbus.exceptions import DBusException + HAVE_DBUS=True +except ImportError: + pass DOCUMENTATION = ''' --- @@ -2277,6 +2282,9 @@ def main(): add_file_common_args=True, ) + if not HAVE_DBUS: + module.fail_json(msg="This module requires dbus python bindings") + module.params['gather_subset'] = ['hardware', 'network', 'virtual', 'facter'] module.params['gather_timeout'] = 10 module.params['filter'] = '*' -- cgit v1.2.3