diff options
Diffstat (limited to 'module/threads')
-rw-r--r-- | module/threads/DecrypterThread.py | 2 | ||||
-rw-r--r-- | module/threads/HookThread.py | 9 | ||||
-rw-r--r-- | module/threads/InfoThread.py | 48 |
3 files changed, 24 insertions, 35 deletions
diff --git a/module/threads/DecrypterThread.py b/module/threads/DecrypterThread.py index a1b7e4f38..8edb97c34 100644 --- a/module/threads/DecrypterThread.py +++ b/module/threads/DecrypterThread.py @@ -4,6 +4,7 @@ from time import sleep from traceback import print_exc +from module.utils import uniqify from module.plugins.Base import Retry from module.plugins.Crypter import Package @@ -54,6 +55,7 @@ class DecrypterThread(BaseThread): plugin.logDebug("Decrypted", plugin_result) result.extend(plugin_result) + result = uniqify(result) pack_names = {} urls = [] diff --git a/module/threads/HookThread.py b/module/threads/HookThread.py index fe4a2a651..bffa72ca0 100644 --- a/module/threads/HookThread.py +++ b/module/threads/HookThread.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- from copy import copy +from traceback import print_exc from BaseThread import BaseThread @@ -48,6 +49,14 @@ class HookThread(BaseThread): del self.kwargs["thread"] self.f(*self.args, **self.kwargs) + except Exception, e: + if hasattr(self.f, "im_self"): + hook = self.f.im_self + hook.logError(_("An Error occured"), e) + if self.m.core.debug: + print_exc() + self.writeDebugReport(hook.__name__, plugin=hook) + finally: local = copy(self.active) for x in local: diff --git a/module/threads/InfoThread.py b/module/threads/InfoThread.py index 596153c4b..c1e4458ef 100644 --- a/module/threads/InfoThread.py +++ b/module/threads/InfoThread.py @@ -30,7 +30,7 @@ class InfoThread(BaseThread): """run method""" plugins = {} - container = [] + crypter = {} for url, plugin in self.data: if plugin in plugins: @@ -42,8 +42,7 @@ class InfoThread(BaseThread): # filter out crypter plugins for name in self.m.core.pluginManager.getPlugins("crypter"): if name in plugins: - container.extend([(name, url) for url in plugins[name]]) - + crypter[name] = plugins[name] del plugins[name] #directly write to database @@ -60,11 +59,10 @@ class InfoThread(BaseThread): self.m.core.files.save() else: #post the results - #TODO: finer crypter control - for name, url in container: + for name, urls in crypter: #attach container content try: - data = self.decryptContainer(name, url) + data = self.decrypt(name, urls) except: print_exc() self.m.log.error("Could not decrypt container.") @@ -169,34 +167,14 @@ class InfoThread(BaseThread): cb(pluginname, result) - def decryptContainer(self, plugin, url): - data = [] - # only works on container plugins - - self.m.log.debug("Pre decrypting %s with %s" % (url, plugin)) - - # dummy pyfile - pyfile = PyFile(self.m.core.files, -1, url, url, 0, 0, "", plugin, -1, -1) - - pyfile.initPlugin() - - # little plugin lifecycle - try: - pyfile.plugin.setup() - pyfile.plugin.loadToDisk() - pyfile.plugin.decrypt(pyfile) - pyfile.plugin.deleteTmp() - - for pack in pyfile.plugin.packages: - pyfile.plugin.urls.extend(pack[1]) - - data, crypter = self.m.core.pluginManager.parseUrls(pyfile.plugin.urls) + def decrypt(self, plugin, urls): + self.m.log.debug("Pre decrypting %s" % plugin) + klass = self.m.core.pluginManager.loadClass("crypter", plugin) - self.m.log.debug("Got %d links." % len(data)) - - except Exception, e: - self.m.log.debug("Pre decrypting error: %s" % str(e)) - finally: - pyfile.release() + # only decrypt files + if has_method(klass, "decryptFile"): + urls = p.decrypt(urls) + data, crypter = self.m.core.pluginManager.parseUrls(urls) + return data - return data + return [] |