Skip to content

Commit

Permalink
Server/Plugins/Ldap: Fix module name
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AlexanderS committed Aug 31, 2017
1 parent e91e384 commit 3b6bfcd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lib/Bcfg2/Server/Plugins/Ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 3b6bfcd

Please sign in to comment.