From 0985c2aed06c14d8b79805d21449f2f1d31dd20c Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 17 Aug 2016 03:28:20 +0200 Subject: 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(-) (limited to 'src') diff --git a/src/lib/Bcfg2/Server/Plugins/Ldap.py b/src/lib/Bcfg2/Server/Plugins/Ldap.py index a51f47dae..770419ba5 100644 --- a/src/lib/Bcfg2/Server/Plugins/Ldap.py +++ b/src/lib/Bcfg2/Server/Plugins/Ldap.py @@ -33,7 +33,8 @@ class ConfigFile(Bcfg2.Server.Plugin.FileBacked): 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] -- cgit v1.2.3-1-g7c22