diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2012-01-07 23:58:28 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2012-01-07 23:58:28 +0100 |
commit | 6eaa7bb25e2254c80c43fe46166142d590e86c64 (patch) | |
tree | 103b12d2f8ca59cf84c7511018d99c3cb651839f /module/threads | |
parent | xfilesharingpro - fix patterns (diff) | |
download | pyload-6eaa7bb25e2254c80c43fe46166142d590e86c64.tar.xz |
some cleanups
Diffstat (limited to 'module/threads')
-rw-r--r-- | module/threads/BaseThread.py | 1 | ||||
-rw-r--r-- | module/threads/DownloadThread.py | 54 | ||||
-rw-r--r-- | module/threads/InfoThread.py | 18 |
3 files changed, 31 insertions, 42 deletions
diff --git a/module/threads/BaseThread.py b/module/threads/BaseThread.py index f4885aadc..526913e9b 100644 --- a/module/threads/BaseThread.py +++ b/module/threads/BaseThread.py @@ -21,6 +21,7 @@ class BaseThread(Thread): Thread.__init__(self) self.setDaemon(True) self.m = manager #thread manager + self.core = manager.core self.log = manager.core.log def writeDebugReport(self, name, pyfile=None, plugin=None): diff --git a/module/threads/DownloadThread.py b/module/threads/DownloadThread.py index 638861338..e140703d5 100644 --- a/module/threads/DownloadThread.py +++ b/module/threads/DownloadThread.py @@ -60,18 +60,18 @@ class DownloadThread(BaseThread): #this pyfile was deleted while queueing pyfile.plugin.checkForSameFiles(starting=True) - self.m.log.info(_("Download starts: %s" % pyfile.name)) + self.log.info(_("Download starts: %s" % pyfile.name)) # start download - self.m.core.hookManager.downloadPreparing(pyfile) + self.core.hookManager.downloadPreparing(pyfile) pyfile.plugin.preprocessing(self) - self.m.log.info(_("Download finished: %s") % pyfile.name) - self.m.core.hookManager.downloadFinished(pyfile) - self.m.core.files.checkPackageFinished(pyfile) + self.log.info(_("Download finished: %s") % pyfile.name) + self.core.hookManager.downloadFinished(pyfile) + self.core.files.checkPackageFinished(pyfile) except NotImplementedError: - self.m.log.error(_("Plugin %s is missing a function.") % pyfile.pluginname) + self.log.error(_("Plugin %s is missing a function.") % pyfile.pluginname) pyfile.setStatus("failed") pyfile.error = "Plugin does not work" self.clean(pyfile) @@ -79,7 +79,7 @@ class DownloadThread(BaseThread): except Abort: try: - self.m.log.info(_("Download aborted: %s") % pyfile.name) + self.log.info(_("Download aborted: %s") % pyfile.name) except: pass @@ -99,7 +99,7 @@ class DownloadThread(BaseThread): except Retry, e: reason = e.args[0] - self.m.log.info(_("Download restarted: %(name)s | %(msg)s") % {"name": pyfile.name, "msg": reason}) + self.log.info(_("Download restarted: %(name)s | %(msg)s") % {"name": pyfile.name, "msg": reason}) self.queue.put(pyfile) continue @@ -108,16 +108,16 @@ class DownloadThread(BaseThread): if msg == "offline": pyfile.setStatus("offline") - self.m.log.warning(_("Download is offline: %s") % pyfile.name) + self.log.warning(_("Download is offline: %s") % pyfile.name) elif msg == "temp. offline": pyfile.setStatus("temp. offline") - self.m.log.warning(_("Download is temporary offline: %s") % pyfile.name) + self.log.warning(_("Download is temporary offline: %s") % pyfile.name) else: pyfile.setStatus("failed") - self.m.log.warning(_("Download failed: %(name)s | %(msg)s") % {"name": pyfile.name, "msg": msg}) + self.log.warning(_("Download failed: %(name)s | %(msg)s") % {"name": pyfile.name, "msg": msg}) pyfile.error = msg - self.m.core.hookManager.downloadFailed(pyfile) + self.core.hookManager.downloadFailed(pyfile) self.clean(pyfile) continue @@ -128,10 +128,10 @@ class DownloadThread(BaseThread): code = 0 msg = e.args - self.m.log.debug("pycurl exception %s: %s" % (code, msg)) + self.log.debug("pycurl exception %s: %s" % (code, msg)) if code in (7, 18, 28, 52, 56): - self.m.log.warning(_("Couldn't connect to host or connection reset, waiting 1 minute and retry.")) + self.log.warning(_("Couldn't connect to host or connection reset, waiting 1 minute and retry.")) wait = time() + 60 pyfile.waitUntil = wait @@ -142,7 +142,7 @@ class DownloadThread(BaseThread): break if pyfile.abort: - self.m.log.info(_("Download aborted: %s") % pyfile.name) + self.log.info(_("Download aborted: %s") % pyfile.name) pyfile.setStatus("aborted") self.clean(pyfile) @@ -153,12 +153,12 @@ class DownloadThread(BaseThread): else: pyfile.setStatus("failed") - self.m.log.error("pycurl error %s: %s" % (code, msg)) - if self.m.core.debug: + self.log.error("pycurl error %s: %s" % (code, msg)) + if self.core.debug: print_exc() self.writeDebugReport(pyfile.pluginname, pyfile) - self.m.core.hookManager.downloadFailed(pyfile) + self.core.hookManager.downloadFailed(pyfile) self.clean(pyfile) continue @@ -166,34 +166,34 @@ class DownloadThread(BaseThread): except SkipDownload, e: pyfile.setStatus("skipped") - self.m.log.info( - _("Download skipped: %(name)s due to %(plugin)s") % {"name": pyfile.name, "plugin": e.message}) + self.log.info(_("Download skipped: %(name)s due to %(plugin)s") + % {"name": pyfile.name, "plugin": e.message}) self.clean(pyfile) - self.m.core.files.checkPackageFinished(pyfile) + self.core.files.checkPackageFinished(pyfile) self.active = False - self.m.core.files.save() + self.core.files.save() continue except Exception, e: pyfile.setStatus("failed") - self.m.log.warning(_("Download failed: %(name)s | %(msg)s") % {"name": pyfile.name, "msg": str(e)}) + self.log.warning(_("Download failed: %(name)s | %(msg)s") % {"name": pyfile.name, "msg": str(e)}) pyfile.error = str(e) - if self.m.core.debug: + if self.core.debug: print_exc() self.writeDebugReport(pyfile.pluginname, pyfile) - self.m.core.hookManager.downloadFailed(pyfile) + self.core.hookManager.downloadFailed(pyfile) self.clean(pyfile) continue finally: - self.m.core.files.save() + self.core.files.save() pyfile.checkIfProcessed() exc_clear() @@ -202,7 +202,7 @@ class DownloadThread(BaseThread): self.active = False pyfile.finishIfDone() - self.m.core.files.save() + self.core.files.save() def put(self, job): diff --git a/module/threads/InfoThread.py b/module/threads/InfoThread.py index c1e4458ef..5f21d487c 100644 --- a/module/threads/InfoThread.py +++ b/module/threads/InfoThread.py @@ -5,9 +5,8 @@ from time import time from traceback import print_exc from module.Api import OnlineStatus -from module.PyFile import PyFile from module.common.packagetools import parseNames -from module.utils import has_method +from module.utils import has_method, accumulate from BaseThread import BaseThread @@ -29,16 +28,9 @@ class InfoThread(BaseThread): def run(self): """run method""" - plugins = {} + plugins = accumulate(self.data) crypter = {} - for url, plugin in self.data: - if plugin in plugins: - plugins[plugin].append(url) - else: - plugins[plugin] = [url] - - # filter out crypter plugins for name in self.m.core.pluginManager.getPlugins("crypter"): if name in plugins: @@ -68,11 +60,7 @@ class InfoThread(BaseThread): self.m.log.error("Could not decrypt container.") data = [] - for url, plugin in data: - if plugin in plugins: - plugins[plugin].append(url) - else: - plugins[plugin] = [url] + accumulate(data, plugins) self.m.infoResults[self.rid] = {} |