summaryrefslogtreecommitdiffstats
path: root/pyload/manager/thread/Info.py
diff options
context:
space:
mode:
authorGravatar Armin <Armin@Armin-PC.diedering.lan> 2015-04-12 17:58:45 +0200
committerGravatar Armin <Armin@Armin-PC.diedering.lan> 2015-04-12 17:58:45 +0200
commitc1d652f22a8f90cacb6749b1661c6ff87ffa625b (patch)
treef7fc0b037f38c8354ca2df5ef4d596f83398555e /pyload/manager/thread/Info.py
parentmoved the config-nicer from config-parser to webui-app (diff)
downloadpyload-c1d652f22a8f90cacb6749b1661c6ff87ffa625b.tar.xz
fix, fix and more fixes
Diffstat (limited to 'pyload/manager/thread/Info.py')
-rw-r--r--pyload/manager/thread/Info.py68
1 files changed, 30 insertions, 38 deletions
diff --git a/pyload/manager/thread/Info.py b/pyload/manager/thread/Info.py
index 4526a07ed..af958fa74 100644
--- a/pyload/manager/thread/Info.py
+++ b/pyload/manager/thread/Info.py
@@ -26,13 +26,13 @@ class InfoThread(PluginThread):
PluginThread.__init__(self, manager)
self.data = data
- self.pid = pid # package id
+ self.pid = pid # package id
# [ .. (name, plugin) .. ]
- self.rid = rid #result id
- self.add = add #add packages instead of return result
+ self.rid = rid # result id
+ self.add = add # add packages instead of return result
- self.cache = [] #accumulated data
+ self.cache = [] # accumulated data
self.start()
@@ -42,35 +42,32 @@ class InfoThread(PluginThread):
plugins = {}
container = []
- for url, plugintype, pluginname in data:
- try:
- plugins[plugintype][pluginname].append(url)
- except Exception:
- plugins[plugintype][pluginname] = [url]
-
- # filter out container plugins
- for name in self.m.core.pluginManager.containerPlugins:
- if name in plugins:
+ for url, plugintype, pluginname in self.data:
+ # filter out container plugins
+ if plugintype == 'container':
container.extend([(name, url) for url in plugins[name]])
+ else:
+ if (plugintype, pluginname) in plugins:
+ plugins[(plugintype, pluginname)].append(url)
+ else:
+ plugins[(plugintype, pluginname)] = [url]
- del plugins[name]
-
- #directly write to database
+ # directly write to database
if self.pid > -1:
- for plugintype, pluginname, urls in plugins.iteritems():
+ for (plugintype, pluginname), urls in plugins.iteritems():
plugin = self.m.core.pluginManager.getPlugin(plugintype, pluginname, True)
if hasattr(plugin, "getInfo"):
self.fetchForPlugin(pluginname, plugin, urls, self.updateDB)
self.m.core.files.save()
elif self.add:
- for plugintype, pluginname, urls in plugins.iteritems():
+ for (plugintype, pluginname), urls in plugins.iteritems():
plugin = self.m.core.pluginManager.getPlugin(plugintype, pluginname, True)
if hasattr(plugin, "getInfo"):
self.fetchForPlugin(pluginname, plugin, urls, self.updateCache, True)
else:
- #generate default result
+ # generate default result
result = [(url, 0, 3, url) for url in urls]
self.updateCache(pluginname, result)
@@ -82,14 +79,13 @@ class InfoThread(PluginThread):
for k, v in packs:
self.m.core.api.addPackage(k, v)
- #empty cache
+ # empty cache
del self.cache[:]
- else: #post the results
-
+ else: # post the results
for name, url in container:
- #attach container content
+ # attach container content
try:
data = self.decryptContainer(name, url)
except Exception:
@@ -110,12 +106,12 @@ class InfoThread(PluginThread):
if hasattr(plugin, "getInfo"):
self.fetchForPlugin(pluginname, plugin, urls, self.updateResult, True)
- #force to process cache
+ # force to process cache
if self.cache:
self.updateResult(pluginname, [], True)
else:
- #generate default result
+ # generate default result
result = [(url, 0, 3, url) for url in urls]
self.updateResult(pluginname, result, True)
@@ -124,20 +120,18 @@ class InfoThread(PluginThread):
self.m.timestamp = time() + 5 * 60
-
def updateDB(self, plugin, result):
self.m.core.files.updateFileInfo(result, self.pid)
def updateResult(self, plugin, result, force=False):
- #parse package name and generate result
- #accumulate results
+ # parse package name and generate result
+ # accumulate results
self.cache.extend(result)
if len(self.cache) >= 20 or force:
- #used for package generating
- tmp = [(name, (url, OnlineStatus(name, plugin, "unknown", status, int(size))))
- for name, size, status, url in self.cache]
+ # used for package generating
+ tmp = [(name, (url, OnlineStatus(name, plugin, "unknown", status, int(size)))) for name, size, status, url in self.cache]
data = parseNames(tmp)
result = {}
@@ -155,8 +149,8 @@ class InfoThread(PluginThread):
def fetchForPlugin(self, pluginname, plugin, urls, cb, err=None):
try:
- result = [] #result loaded from cache
- process = [] #urls to process
+ result = [] # result loaded from cache
+ process = [] # urls to process
for url in urls:
if url in self.m.infoCache:
result.append(self.m.infoCache[url])
@@ -170,19 +164,18 @@ class InfoThread(PluginThread):
if process:
self.m.log.debug("Run Info Fetching for %s" % pluginname)
for result in plugin.getInfo(process):
- #result = [ .. (name, size, status, url) .. ]
+ # result = [ .. (name, size, status, url) .. ]
if not type(result) == list:
result = [result]
for res in result:
- self.m.infoCache[res[3]] = res #: why don't assign res dict directly?
+ self.m.infoCache[res[3]] = res # : why don't assign res dict directly?
cb(pluginname, result)
self.m.log.debug("Finished Info Fetching for %s" % pluginname)
except Exception, e:
- self.m.log.warning(_("Info Fetching for %(name)s failed | %(err)s") %
- {"name": pluginname, "err": str(e)})
+ self.m.log.warning(_("Info Fetching for %(name)s failed | %(err)s") % {"name": pluginname, "err": str(e)})
if self.m.core.debug:
print_exc()
@@ -191,7 +184,6 @@ class InfoThread(PluginThread):
result = [(url, 0, 3, url) for url in urls]
cb(pluginname, result)
-
def decryptContainer(self, plugin, url):
data = []
# only works on container plugins