From bd2d1caa0ab8f83500633d011b8c01b4213484fc Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 10 Nov 2011 17:06:28 +0100 Subject: Autoload plugins in session_start instead of core.__init__ --- src/core.py | 3 +-- src/plugin_manager.py | 10 ++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/core.py b/src/core.py index 986d1222..3ecf76f2 100644 --- a/src/core.py +++ b/src/core.py @@ -177,8 +177,6 @@ class Core(object): self.connected_events = {} - self.autoload_plugins() - def autoload_plugins(self): plugins = config.get('plugins_autoload', '') for plugin in plugins.split(): @@ -456,6 +454,7 @@ class Core(object): Called when we are connected and authenticated """ self.connection_time = time.time() + self.autoload_plugins() self.information(_("Authentication success.")) self.information(_("Your JID is %s") % self.xmpp.boundjid.full) if not self.xmpp.anon: diff --git a/src/plugin_manager.py b/src/plugin_manager.py index 36887084..fe4d2b7e 100644 --- a/src/plugin_manager.py +++ b/src/plugin_manager.py @@ -37,7 +37,7 @@ class PluginManager(object): self.event_handlers = {} # module name -> list of event_name/handler pairs loaded for the module self.tab_commands = {} #module name -> dict of tab types; tab type -> commands loaded by the module - def load(self, name): + def load(self, name, notify=True): if name in self.plugins: self.unload(name) @@ -64,9 +64,10 @@ class PluginManager(object): self.tab_commands[name] = {} self.event_handlers[name] = [] self.plugins[name] = module.Plugin(self, self.core, plugins_conf_dir) - self.core.information('Plugin %s loaded' % name, 'Info') + if notify: + self.core.information('Plugin %s loaded' % name, 'Info') - def unload(self, name): + def unload(self, name, notify=True): if name in self.plugins: try: for command in self.commands[name].keys(): @@ -83,7 +84,8 @@ class PluginManager(object): del self.commands[name] del self.tab_commands[name] del self.event_handlers[name] - self.core.information('Plugin %s unloaded' % name, 'Info') + if notify: + self.core.information('Plugin %s unloaded' % name, 'Info') except Exception as e: import traceback self.core.information(_("Could not unload plugin (may not be safe to try again): ") + traceback.format_exc()) -- cgit v1.2.3