From a606d0ed7dc44e4c79dcc4b3a2de7c2950d1e8b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Mon, 13 Feb 2017 11:35:17 +0100 Subject: [PATCH 1/3] Activate PluginInstaller in plugin window init --- src/plugins/gui.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/plugins/gui.py b/src/plugins/gui.py index 5867785db..7733261f4 100644 --- a/src/plugins/gui.py +++ b/src/plugins/gui.py @@ -114,6 +114,11 @@ class PluginsWindow(object): self.plugins_notebook.set_current_page(0) self.xml.get_object('close_button').grab_focus() + for plugin in gajim.plugin_manager.active_plugins: + if type(plugin).__name__ == 'PluginInstaller': + plugin.on_activate(self) + break + self.window.show_all() gtkgui_helpers.possibly_move_window_in_current_desktop(self.window) From 8e8605615fd9bb0dfca15c98afb3337a663cd9be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Thu, 23 Feb 2017 17:56:19 +0100 Subject: [PATCH 2/3] Add scanning single plugins --- src/plugins/pluginmanager.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/plugins/pluginmanager.py b/src/plugins/pluginmanager.py index 6ee0974e5..3b2afd701 100644 --- a/src/plugins/pluginmanager.py +++ b/src/plugins/pluginmanager.py @@ -403,20 +403,25 @@ class PluginManager(metaclass=Singleton): @staticmethod @log_calls('PluginManager') - def scan_dir_for_plugins(path, scan_dirs=True): + def scan_dir_for_plugins(path, scan_dirs=True, package=False): r''' Scans given directory for plugin classes. :param path: directory to scan for plugins :type path: str + :param scan_dirs: folders inside path are processed as modules + :type scan_dirs: boolean + + :param package: if path points to a single package folder + :type package: boolean + :return: list of found plugin classes (subclasses of `GajimPlugin` :rtype: [] of class objects :note: currently it only searches for plugin classes in '\*.py' files present in given direcotory `path` (no recursion here) - :todo: add scanning packages :todo: add scanning zipped modules ''' from plugins.plugins_i18n import _ @@ -427,7 +432,11 @@ class PluginManager(metaclass=Singleton): if not os.path.isdir(path): return plugins_found - dir_list = os.listdir(path) + if package: + path, package_name = os.path.split(path) + dir_list = [package_name] + else: + dir_list = os.listdir(path) sys.path.insert(0, path) @@ -439,6 +448,8 @@ class PluginManager(metaclass=Singleton): elif os.path.isdir(file_path) and scan_dirs: module_name = elem_name file_path += os.path.sep + else: + continue manifest_path = os.path.join(os.path.dirname(file_path), 'manifest.ini') From 5c11e240b19b8174345de6ecd82269e2d2200c7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Thu, 23 Feb 2017 17:57:11 +0100 Subject: [PATCH 3/3] Reload plugins if already loaded --- src/plugins/pluginmanager.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/plugins/pluginmanager.py b/src/plugins/pluginmanager.py index 3b2afd701..eeeafcb04 100644 --- a/src/plugins/pluginmanager.py +++ b/src/plugins/pluginmanager.py @@ -493,11 +493,14 @@ class PluginManager(metaclass=Singleton): module = None - if module_name in sys.modules: - # do not load the module twice - continue try: - module = __import__(module_name) + if module_name in sys.modules: + from imp import reload + log.info('Reloading %s', module_name) + module = reload(sys.modules[module_name]) + else: + log.info('Loading %s', module_name) + module = __import__(module_name) except Exception as error: log.warning( "While trying to load {plugin}, exception occurred".format(plugin=elem_name),