Philipp Hörist pushed to branch master at gajim / gajim
Commits:
a606d0ed by Philipp Hörist at 2017-02-19T18:13:10+01:00
Activate PluginInstaller in plugin window init
- - - - -
8e860561 by Philipp Hörist at 2017-02-23T17:56:19+01:00
Add scanning single plugins
- - - - -
5c11e240 by Philipp Hörist at 2017-02-23T17:57:11+01:00
Reload plugins if already loaded
- - - - -
a40c0784 by Philipp Hörist at 2017-02-25T15:37:33+01:00
Merge branch 'small-fixes' into 'master'
Plugin Installer Version 0.18
See merge request !61
- - - - -
2 changed files:
- src/plugins/gui.py
- src/plugins/pluginmanager.py
Changes:
=====================================
src/plugins/gui.py
=====================================
--- 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)
=====================================
src/plugins/pluginmanager.py
=====================================
--- 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')
@@ -482,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),
View it on GitLab:
https://dev.gajim.org/gajim/gajim/compare/18df7163d11c72800cb902377962d7550aa95b81...a40c07842001b8907f28d6d25d08871213eab755
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits