From 9e4ee7bb31910af91c51a67c42f3ff9bdcddbaae Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 29 Aug 2016 09:56:21 -0400 Subject: [PATCH] Fix conflicts with system python modules If python system module had a name that conflicted in some way with a plugin, the plugin load would fail. Fix this by prioritizing the plugin path over system locations. Also, to avoid the breakage going the other way, remove the plugindir from the system path when that particular directory is done. --- confluent_server/confluent/core.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/confluent_server/confluent/core.py b/confluent_server/confluent/core.py index 5bd29bbd..e7e6a98e 100644 --- a/confluent_server/confluent/core.py +++ b/confluent_server/confluent/core.py @@ -78,7 +78,7 @@ def load_plugins(): plugindir = os.path.join(plugintop, plugindir) if not os.path.isdir(plugindir): continue - sys.path.append(plugindir) + sys.path.insert(1, plugindir) # two passes, to avoid adding both py and pyc files for plugin in os.listdir(plugindir): if plugin.startswith('.'): @@ -96,6 +96,8 @@ def load_plugins(): pluginmap[name] = tmpmod else: pluginmap[plugin] = tmpmod + # restore path to not include the plugindir + sys.path.pop(1) rootcollections = ['noderange/', 'nodes/', 'nodegroups/', 'users/', 'events/']