From 3b6bfcd685e410fa19c50b8209a9da8bebe779bb Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 17 Aug 2016 03:28:20 +0200 Subject: [PATCH] Server/Plugins/Ldap: Fix module name If the module name contains slashes, python will issue an warning: > Ldap/config.py:1: RuntimeWarning: Parent module '__Ldap_/root/repo/Ldap/config' not found while handling absolute import > from Bcfg2.Server.Plugins.Ldap import LdapConnection, LdapQuery So we simply use the basename without the file extension for the module name. --- src/lib/Bcfg2/Server/Plugins/Ldap.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/Bcfg2/Server/Plugins/Ldap.py b/src/lib/Bcfg2/Server/Plugins/Ldap.py index a51f47dae4..770419ba59 100644 --- a/src/lib/Bcfg2/Server/Plugins/Ldap.py +++ b/src/lib/Bcfg2/Server/Plugins/Ldap.py @@ -33,7 +33,8 @@ def __init__(self, name, core, plugin): def Index(self): """ Get the queries from the config file """ try: - module = imp.load_source(safe_module_name('Ldap', self.name), + module_name = os.path.splitext(os.path.basename(self.name))[0] + module = imp.load_source(safe_module_name('Ldap', module_name), self.name) except: # pylint: disable=W0702 err = sys.exc_info()[1]