summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--module/HookManager.py29
-rwxr-xr-xpyLoadCore.py1
2 files changed, 16 insertions, 14 deletions
diff --git a/module/HookManager.py b/module/HookManager.py
index 41908bc47..d0ceb89b2 100644
--- a/module/HookManager.py
+++ b/module/HookManager.py
@@ -53,18 +53,20 @@ class HookManager:
@lock
def callInHooks(self, event, *args):
- """ Calls a method in hook and catch / log errors"""
+ """ Calls a method in all hooks and catch / log errors"""
for plugin in self.plugins.itervalues():
- try:
- func = getattr(plugin, event)
- return func(*args)
- except Exception, e:
- plugin.logError(_("Error executing %s" % event), e)
- if self.core.debug:
- print_exc()
-
+ self.call(plugin, event, *args)
self.dispatchEvent(event, *args)
+ def call(self, hook, f, *args):
+ try:
+ func = getattr(hook, f)
+ return func(*args)
+ except Exception, e:
+ plugin.logError(_("Error executing %s" % event), e)
+ if self.core.debug:
+ print_exc()
+
def addRPC(self, plugin, func, doc):
plugin = plugin.rpartition(".")[2]
doc = doc.strip() if doc else ""
@@ -147,7 +149,7 @@ class HookManager:
else:
hook = self.plugins[plugin]
- hook.deactivate()
+ self.call(hook, "deactivate")
self.log.debug("Plugin deactivated: %s" % plugin)
#remove periodic call
@@ -161,15 +163,16 @@ class HookManager:
self.core.eventManager.removeFromEvents(getattr(hook, f))
def activateHooks(self):
+ self.log.info(_("Activating Plugins..."))
for plugin in self.plugins.itervalues():
if plugin.isActivated():
- plugin.activate()
+ self.call(plugin, "activate")
def deactivateHooks(self):
""" Called when core is shutting down """
+ self.log.info(_("Deactivating Plugins..."))
for plugin in self.plugins.itervalues():
- if plugin.isActivated():
- plugin.deactivate()
+ self.call(plugin, "deactivate")
def downloadPreparing(self, pyfile):
self.callInHooks("downloadPreparing", pyfile)
diff --git a/pyLoadCore.py b/pyLoadCore.py
index 54dc9ca39..5e32219f8 100755
--- a/pyLoadCore.py
+++ b/pyLoadCore.py
@@ -438,7 +438,6 @@ class Core(object):
self.threadManager.pause = False
self.running = True
- self.log.info(_("Activating Plugins..."))
self.hookManager.activateHooks()
self.log.info(_("pyLoad is up and running"))