Philipp Hörist pushed to branch master at gajim / gajim

Commits:
7e0e4cce by Philipp Hörist at 2017-08-07T19:28:54+02:00
PluginManager: remove plugin path from sys.path

Remove plugin path from sys.path after importing.

If we scan multiple plugin dirs and never remove the path from
sys.path, it is hard to predict from which path python will import
a package.

The chance that the same plugin package is in multiple plugin paths
is high.

- - - - -
635ce528 by Philipp Hörist at 2017-08-07T20:02:03+02:00
PluginManager: prefer plugins in user path

As we always load plugins from the user path first, we should not
reload them later from Gajims plugin base dir

- - - - -


1 changed file:

- gajim/plugins/pluginmanager.py


Changes:

=====================================
gajim/plugins/pluginmanager.py
=====================================
--- a/gajim/plugins/pluginmanager.py
+++ b/gajim/plugins/pluginmanager.py
@@ -531,6 +531,11 @@ class PluginManager(metaclass=Singleton):
 
             try:
                 if module_name in sys.modules:
+                    if path == gajim.PLUGINS_DIRS[0]:
+                        # Only reload plugins from Gajim base dir when they
+                        # dont exist. This means plugins in the user path are
+                        # always preferred.
+                        continue
                     from imp import reload
                     log.info('Reloading %s', module_name)
                     module = reload(sys.modules[module_name])
@@ -589,6 +594,7 @@ class PluginManager(metaclass=Singleton):
                     log.debug('%s : %s' % (module_attr_name,
                         'wrong manifest file. section are required!'))
 
+        sys.path.remove(path)
         return plugins_found
 
     def install_from_zip(self, zip_filename, owerwrite=None):



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/compare/413c7f52d7123248cbb9b2cce1f4ec99a123ade2...635ce52856d4a71f4b2f9928e30bbe89d25847c7

---
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/compare/413c7f52d7123248cbb9b2cce1f4ec99a123ade2...635ce52856d4a71f4b2f9928e30bbe89d25847c7
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
Commits@gajim.org
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to