summaryrefslogtreecommitdiffstats
path: root/module/PluginThread.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/PluginThread.py')
-rw-r--r--module/PluginThread.py59
1 files changed, 26 insertions, 33 deletions
diff --git a/module/PluginThread.py b/module/PluginThread.py
index 051236c3e..56c36c778 100644
--- a/module/PluginThread.py
+++ b/module/PluginThread.py
@@ -155,7 +155,7 @@ class DownloadThread(PluginThread):
"""Constructor"""
PluginThread.__init__(self, manager)
- self.queue = Queue() #: job queue
+ self.queue = Queue() # job queue
self.active = False
self.start()
@@ -176,8 +176,7 @@ class DownloadThread(PluginThread):
return True
try:
- if not pyfile.hasPlugin():
- continue
+ if not pyfile.hasPlugin(): continue
#this pyfile was deleted while queueing
pyfile.plugin.checkForSameFiles(starting=True)
@@ -185,7 +184,6 @@ class DownloadThread(PluginThread):
# start download
self.m.core.hookManager.downloadPreparing(pyfile)
- pyfile.error = ""
pyfile.plugin.preprocessing(self)
self.m.log.info(_("Download finished: %s") % pyfile.name)
@@ -207,9 +205,6 @@ class DownloadThread(PluginThread):
pyfile.setStatus("aborted")
- if self.m.core.debug:
- print_exc()
-
self.clean(pyfile)
continue
@@ -242,9 +237,6 @@ class DownloadThread(PluginThread):
self.m.log.warning(_("Download failed: %(name)s | %(msg)s") % {"name": pyfile.name, "msg": msg})
pyfile.error = msg
- if self.m.core.debug:
- print_exc()
-
self.m.core.hookManager.downloadFailed(pyfile)
self.clean(pyfile)
continue
@@ -325,7 +317,7 @@ class DownloadThread(PluginThread):
pyfile.checkIfProcessed()
exc_clear()
-
+
#pyfile.plugin.req.clean()
self.active = False
@@ -367,46 +359,41 @@ class DecrypterThread(PluginThread):
retry = False
try:
- self.m.log.info(_("Decrypting starts: %s") % pyfile.name)
- pyfile.error = ""
- pyfile.plugin.preprocessing(self)
+ self.m.log.info(_("Decrypting starts: %s") % self.active.name)
+ self.active.plugin.preprocessing(self)
except NotImplementedError:
- self.m.log.error(_("Plugin %s is missing a function.") % pyfile.pluginname)
+ self.m.log.error(_("Plugin %s is missing a function.") % self.active.pluginname)
return
except Fail, e:
msg = e.args[0]
if msg == "offline":
- pyfile.setStatus("offline")
- self.m.log.warning(_("Download is offline: %s") % pyfile.name)
+ self.active.setStatus("offline")
+ self.m.log.warning(_("Download is offline: %s") % self.active.name)
else:
- pyfile.setStatus("failed")
- self.m.log.error(_("Decrypting failed: %(name)s | %(msg)s") % {"name": pyfile.name, "msg": msg})
- pyfile.error = msg
+ self.active.setStatus("failed")
+ self.m.log.error(_("Decrypting failed: %(name)s | %(msg)s") % {"name": self.active.name, "msg": msg})
+ self.active.error = msg
- if self.m.core.debug:
- print_exc()
return
except Abort:
self.m.log.info(_("Download aborted: %s") % pyfile.name)
pyfile.setStatus("aborted")
- if self.m.core.debug:
- print_exc()
return
except Retry:
- self.m.log.info(_("Retrying %s") % pyfile.name)
+ self.m.log.info(_("Retrying %s") % self.active.name)
retry = True
return self.run()
except Exception, e:
- pyfile.setStatus("failed")
- self.m.log.error(_("Decrypting failed: %(name)s | %(msg)s") % {"name": pyfile.name, "msg": str(e)})
- pyfile.error = str(e)
+ self.active.setStatus("failed")
+ self.m.log.error(_("Decrypting failed: %(name)s | %(msg)s") % {"name": self.active.name, "msg": str(e)})
+ self.active.error = str(e)
if self.m.core.debug:
print_exc()
@@ -414,14 +401,21 @@ class DecrypterThread(PluginThread):
return
+
finally:
if not retry:
- pyfile.release()
+ self.active.release()
self.active = False
self.m.core.files.save()
self.m.localThreads.remove(self)
exc_clear()
+
+ #self.m.core.hookManager.downloadFinished(pyfile)
+
+
+ #self.m.localThreads.remove(self)
+ #self.active.finishIfDone()
if not retry:
pyfile.delete()
@@ -467,7 +461,7 @@ class HookThread(PluginThread):
#dirty method to filter out exceptions
if "unexpected keyword argument 'thread'" not in e.args[0]:
raise
-
+
del self.kwargs["thread"]
self.f(*self.args, **self.kwargs)
finally:
@@ -630,10 +624,9 @@ class InfoThread(PluginThread):
self.m.log.debug("Run Info Fetching for %s" % pluginname)
for result in plugin.getInfo(process):
#result = [ .. (name, size, status, url) .. ]
- if not type(result) == list:
- result = [result]
+ if not type(result) == list: result = [result]
- for res in result: #: why don't assign res dict directly?
+ for res in result:
self.m.infoCache[res[3]] = res
cb(pluginname, result)