diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-08-18 19:16:51 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-08-18 19:16:51 +0200 |
commit | 4d3d6105df18608654bbc42594723bd9f767f77d (patch) | |
tree | ba0eda69d71fce60337384a408a29aa927189640 /pyload | |
parent | renaming of packages (diff) | |
download | pyload-4d3d6105df18608654bbc42594723bd9f767f77d.tar.xz |
fixed online status fetching
Diffstat (limited to 'pyload')
-rw-r--r-- | pyload/remote/wsbackend/AsyncHandler.py | 2 | ||||
-rw-r--r-- | pyload/threads/InfoThread.py | 4 | ||||
-rw-r--r-- | pyload/threads/ThreadManager.py | 25 | ||||
-rw-r--r-- | pyload/web/app/scripts/models/CollectorPackage.js | 4 | ||||
-rw-r--r-- | pyload/web/app/scripts/views/linkgrabber/collectorView.js | 10 | ||||
-rw-r--r-- | pyload/web/app/scripts/views/linkgrabber/modalView.js | 10 | ||||
-rw-r--r-- | pyload/web/app/scripts/views/linkgrabber/packageView.js | 8 | ||||
-rw-r--r-- | pyload/web/app/styles/default/linkgrabber.less | 15 | ||||
-rw-r--r-- | pyload/web/app/templates/default/linkgrabber/package.html | 6 |
9 files changed, 66 insertions, 18 deletions
diff --git a/pyload/remote/wsbackend/AsyncHandler.py b/pyload/remote/wsbackend/AsyncHandler.py index d53d6bcea..527834b7c 100644 --- a/pyload/remote/wsbackend/AsyncHandler.py +++ b/pyload/remote/wsbackend/AsyncHandler.py @@ -44,7 +44,7 @@ class AsyncHandler(AbstractHandler): COMMAND = "start" PROGRESS_INTERVAL = 1.5 - EVENT_PATTERN = re.compile(r"^(package|file|interaction)", re.I) + EVENT_PATTERN = re.compile(r"^(package|file|interaction|linkcheck)", re.I) INTERACTION = Interaction.All def __init__(self, api): diff --git a/pyload/threads/InfoThread.py b/pyload/threads/InfoThread.py index 6e685cdcf..ff77117c9 100644 --- a/pyload/threads/InfoThread.py +++ b/pyload/threads/InfoThread.py @@ -65,8 +65,8 @@ class InfoThread(BaseThread): self.m.infoResults[self.rid] = {} for pluginname, urls in plugins.iteritems(): - plugin = self.m.core.pluginManager.getPlugin(pluginname, True) - klass = getattr(plugin, pluginname) + plugin = self.m.core.pluginManager.getPluginModule(pluginname) + klass = self.m.core.pluginManager.getPluginClass(pluginname) if has_method(klass, "getInfo"): self.fetchForPlugin(pluginname, plugin, urls, self.updateResult, True) #force to process cache diff --git a/pyload/threads/ThreadManager.py b/pyload/threads/ThreadManager.py index a2e0aa400..9ad23138a 100644 --- a/pyload/threads/ThreadManager.py +++ b/pyload/threads/ThreadManager.py @@ -35,6 +35,7 @@ from DecrypterThread import DecrypterThread from DownloadThread import DownloadThread from InfoThread import InfoThread + class ThreadManager: """manages the download threads, assign jobs, reconnect etc""" @@ -92,7 +93,13 @@ class ThreadManager: rid = self.resultIDs self.resultIDs += 1 - InfoThread(self, data, rid=rid) + # maps url to plugin + urls = [] + for links in data.itervalues(): + for link in links: + urls.append((link.url, link.plugin)) + + InfoThread(self, urls, rid=rid) return rid @@ -116,7 +123,7 @@ class ThreadManager: @lock def setInfoResults(self, rid, result): - self.core.evm.dispatchEvent("onlineResult:updated", rid, result) + self.core.evm.dispatchEvent("linkcheck:updated", rid, result) self.infoResults[rid].update(result) def getActiveDownloads(self, user=None): @@ -153,7 +160,7 @@ class ThreadManager: try: self.tryReconnect() except Exception, e: - self.log.error(_("Reconnect Failed: %s") % str(e) ) + self.log.error(_("Reconnect Failed: %s") % str(e)) self.reconnecting.clear() self.core.print_exc() @@ -164,7 +171,7 @@ class ThreadManager: except Exception, e: self.log.warning("Assign job error", e) self.core.print_exc() - + sleep(0.5) self.assignJob() #it may be failed non critical so we try it again @@ -229,7 +236,7 @@ class ThreadManager: def getIP(self): """retrieve current ip""" services = [("http://automation.whatismyip.com/n09230945.asp", "(\S+)"), - ("http://checkip.dyndns.org/",".*Current IP Address: (\S+)</body>.*")] + ("http://checkip.dyndns.org/", ".*Current IP Address: (\S+)</body>.*")] ip = "" for i in range(10): @@ -278,10 +285,12 @@ class ThreadManager: free = [x for x in self.threads if not x.active] - inuse = [(x.active.pluginname, x.active.plugin.getDownloadLimit()) for x in self.threads if x.active and x.active.hasPlugin()] - inuse = [(x[0], x[1], len([y for y in self.threads if y.active and y.active.pluginname == x[0]])) for x in inuse] + inuse = [(x.active.pluginname, x.active.plugin.getDownloadLimit()) for x in self.threads if + x.active and x.active.hasPlugin()] + inuse = [(x[0], x[1], len([y for y in self.threads if y.active and y.active.pluginname == x[0]])) for x in + inuse] occ = tuple(sorted(uniqify([x[0] for x in inuse if 0 < x[1] <= x[2]]))) - + job = self.core.files.getJob(occ) if job: try: diff --git a/pyload/web/app/scripts/models/CollectorPackage.js b/pyload/web/app/scripts/models/CollectorPackage.js index 1bba59f67..e5625d7bd 100644 --- a/pyload/web/app/scripts/models/CollectorPackage.js +++ b/pyload/web/app/scripts/models/CollectorPackage.js @@ -61,6 +61,7 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'collection }; var links = this.get('links'); data.length = links.length; + data.size = 0; data.online = 0; data.offline = 0; data.unknown = 0; @@ -73,6 +74,9 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'collection data.offline++; else data.unknown++; + + if (link.get('size') > 0) + data.size += link.get('size'); }); return data; diff --git a/pyload/web/app/scripts/views/linkgrabber/collectorView.js b/pyload/web/app/scripts/views/linkgrabber/collectorView.js index d2b43f699..a02023a30 100644 --- a/pyload/web/app/scripts/views/linkgrabber/collectorView.js +++ b/pyload/web/app/scripts/views/linkgrabber/collectorView.js @@ -3,6 +3,15 @@ define(['jquery', 'underscore', 'backbone', 'app', './packageView'], 'use strict'; return Backbone.Marionette.CollectionView.extend({ itemView: packageView, + + initialize: function() { + this.listenTo(App.vent, 'linkcheck:updated', _.bind(this.onData, this)); + }, + + onData: function(rid, result) { + this.updateData({data: result}); + }, + updateData: function(result) { var self = this; _.each(result.data, function(links, name) { @@ -16,6 +25,5 @@ define(['jquery', 'underscore', 'backbone', 'app', './packageView'], pack.updateLinks(links); }); } - }); });
\ No newline at end of file diff --git a/pyload/web/app/scripts/views/linkgrabber/modalView.js b/pyload/web/app/scripts/views/linkgrabber/modalView.js index 6e4781ac2..32730658c 100644 --- a/pyload/web/app/scripts/views/linkgrabber/modalView.js +++ b/pyload/web/app/scripts/views/linkgrabber/modalView.js @@ -4,6 +4,7 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/CollectorPackage', 'v // Modal dialog for package adding - triggers package:added when package was added return modalView.extend({ + className: 'modal linkgrabber', events: { 'keypress #inputLinks': 'addOnEnter' }, @@ -16,6 +17,7 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/CollectorPackage', 'v initialize: function() { // Inherit parent events this.events = _.extend({}, modalView.prototype.events, this.events); + this.listenTo(App.vent, 'package:added', _.bind(this.onAdded, this)); }, addOnEnter: function(e) { @@ -44,6 +46,14 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/CollectorPackage', 'v this.$('#inputLinks').val(''); }, + // Hide when there are no more packages + onAdded: function() { + if (this.collectorView !== null) { + if (this.collectorView.collection.length === 0) + this.hide(); + } + }, + onRender: function() { // anonymous collection this.collectorView = new CollectorView({collection: new (Backbone.Collection.extend({ diff --git a/pyload/web/app/scripts/views/linkgrabber/packageView.js b/pyload/web/app/scripts/views/linkgrabber/packageView.js index 89a307d2f..95c46e3cc 100644 --- a/pyload/web/app/scripts/views/linkgrabber/packageView.js +++ b/pyload/web/app/scripts/views/linkgrabber/packageView.js @@ -33,8 +33,10 @@ define(['jquery', 'underscore', 'backbone', 'app', 'hbs!tpl/linkgrabber/package' return data; }, - addPackage: function() { + addPackage: function(e) { + e.stopPropagation(); this.model.add(); + return false; }, renamePackage: function() { @@ -63,9 +65,11 @@ define(['jquery', 'underscore', 'backbone', 'app', 'hbs!tpl/linkgrabber/package' this.render(); }, - expand: function() { + expand: function(e) { + e.stopPropagation(); this.expanded ^= true; this.ui.table.toggle(); + return false; } }); diff --git a/pyload/web/app/styles/default/linkgrabber.less b/pyload/web/app/styles/default/linkgrabber.less index 39df28276..8ed6d1dc5 100644 --- a/pyload/web/app/styles/default/linkgrabber.less +++ b/pyload/web/app/styles/default/linkgrabber.less @@ -1,10 +1,19 @@ +.linkgrabber { + width: 700px !important; +} + .prepared-packages { hr { margin: 0; } - .package > .btn { - margin-bottom: 3px; + .package { + margin-bottom: 10px; + + & > .btn { + margin-bottom: 3px; + } + } .name { @@ -18,7 +27,7 @@ border: 1px @grey dashed; } - &.edit { + &.edit { border: none; input { display: inline; diff --git a/pyload/web/app/templates/default/linkgrabber/package.html b/pyload/web/app/templates/default/linkgrabber/package.html index cd62e913b..ed699f0d5 100644 --- a/pyload/web/app/templates/default/linkgrabber/package.html +++ b/pyload/web/app/templates/default/linkgrabber/package.html @@ -9,6 +9,7 @@ <tr> <td>{{ name }}</td> <td><img src="{{ pluginIcon plugin }}"> {{ plugin }}</td> + <td>{{formatSize size }}</td> <td>{{ linkStatus status }}</td> <td><button class="btn btn-danger btn-mini" data-index={{@index}}><i class="icon-trash"></i></button></td> </tr> @@ -16,7 +17,10 @@ </tbody> </table> <hr> -{{ ngettext "%d link" "%d links" length }}: +{{ ngettext "%d link" "%d links" length }} +{{#if size}} + - {{formatSize size}} +{{/if}} : {{#if online}} <span class="text-success"> {{ online }} {{_ "online" }} |