summaryrefslogtreecommitdiff
path: root/src/plugin_manager.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2014-04-13 23:13:18 +0200
committermathieui <mathieui@mathieui.net>2014-04-13 23:13:18 +0200
commite3859c2862b441059012e51cbd9e7eccc6b13470 (patch)
tree0b3cc50dd224144dc85642e5dbc56f4353dfa857 /src/plugin_manager.py
parent9c2203e7e37f1eefea2bbd20ce22d107bee93636 (diff)
downloadpoezio-e3859c2862b441059012e51cbd9e7eccc6b13470.tar.gz
poezio-e3859c2862b441059012e51cbd9e7eccc6b13470.tar.bz2
poezio-e3859c2862b441059012e51cbd9e7eccc6b13470.tar.xz
poezio-e3859c2862b441059012e51cbd9e7eccc6b13470.zip
Do not load a plugin if its init() traceback
and show a somehow helpful error message in this case
Diffstat (limited to 'src/plugin_manager.py')
-rw-r--r--src/plugin_manager.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/plugin_manager.py b/src/plugin_manager.py
index c58082e9..b3816939 100644
--- a/src/plugin_manager.py
+++ b/src/plugin_manager.py
@@ -92,10 +92,17 @@ class PluginManager(object):
self.tab_keys[name] = {}
self.tab_commands[name] = {}
self.event_handlers[name] = []
- self.plugins[name] = module.Plugin(self.plugin_api, self.core, self.plugins_conf_dir)
-
- if notify:
- self.core.information('Plugin %s loaded' % name, 'Info')
+ try:
+ self.plugins[name] = None
+ self.plugins[name] = module.Plugin(self.plugin_api, self.core, self.plugins_conf_dir)
+ except Exception as e:
+ log.error('Error while loading the plugin %s', name, exc_info=True)
+ if notify:
+ self.core.information('Unable to load the plugin %s: %s' % (name, e), 'Error')
+ self.unload(name, notify=False)
+ else:
+ if notify:
+ self.core.information('Plugin %s loaded' % name, 'Info')
def unload(self, name, notify=True):
if name in self.plugins:
@@ -115,7 +122,8 @@ class PluginManager(object):
for event_name, handler in self.event_handlers[name][:]:
self.del_event_handler(name, event_name, handler)
- self.plugins[name].unload()
+ if self.plugins[name] is not None:
+ self.plugins[name].unload()
del self.plugins[name]
del self.commands[name]
del self.keys[name]