def getProgressInfo(self): return ProgressInfo( self.pluginname, self.name, self.getStatusName(), self.getETA(), self.getBytesArrived(), self.getSize(), self.owner, ProgressType.Download, DownloadProgress(self.fid, self.packageid, self.getSpeed(), self.getFlags(), self.status))
def run(self): plugins = accumulate(self.data) crypter = {} # db or info result cb = self.updateDB if self.pid > 1 else self.updateResult # filter out crypter plugins for name in self.m.core.pluginManager.getPlugins("crypter"): if name in plugins: crypter[name] = plugins[name] del plugins[name] if crypter: # decrypt them links, packages = self.decrypt(crypter, err=True) # push these as initial result and save package names cb(links) for pack in packages: for url in pack.getURLs(): self.names[url] = pack.name links.extend(pack.links) cb(pack.links) # TODO: no plugin information pushed to GUI # parse links and merge hoster, crypter = self.m.core.pluginManager.parseUrls( [l.url for l in links]) accumulate(hoster + crypter, plugins) self.progress = ProgressInfo( "BasePlugin", "", _("online check"), 0, 0, sum(len(urls) for urls in plugins.itervalues()), self.owner, ProgressType.LinkCheck) for pluginname, urls in plugins.iteritems(): plugin = self.m.core.pluginManager.loadModule("hoster", pluginname) klass = self.m.core.pluginManager.getPluginClass("hoster", pluginname, overwrite=False) if has_method(klass, "getInfo"): self.fetchForPlugin(klass, urls, cb) # TODO: this branch can be removed in the future elif has_method(plugin, "getInfo"): self.log.debug( "Deprecated .getInfo() method on module level, use staticmethod instead" ) self.fetchForPlugin(plugin, urls, cb) if self.oc: self.oc.done = True self.names.clear() self.m.timestamp = time() + 5 * 60 self.progress = None self.finished()
def decrypt(self, plugin_map, password=None, err=False): result = [] self.progress = ProgressInfo("BasePlugin", "", _("decrypting"), 0, 0, len(self.data), self.owner, ProgressType.Decrypting) # TODO QUEUE_DECRYPT for name, urls in plugin_map.iteritems(): klass = self.core.pluginManager.loadClass("crypter", name) plugin = None plugin_result = [] # updating progress self.progress.plugin = name self.progress.name = _("Decrypting %s links") % len(urls) if len( urls) > 1 else urls[0] #TODO: dependency check, there is a new error code for this # TODO: decrypting with result yielding if not klass: self.error = True if err: plugin_result.extend( LinkStatus(url, url, -1, DS.NotPossible, name) for url in urls) self.log.debug("Plugin '%s' for decrypting was not loaded" % name) else: try: plugin = klass(self.core, password) try: plugin_result = plugin._decrypt(urls) except Retry: sleep(1) plugin_result = plugin._decrypt(urls) plugin.logDebug("Decrypted", plugin_result) except Abort: plugin.logInfo(_("Decrypting aborted")) except Exception, e: plugin.logError(_("Decrypting failed"), e) self.error = True # generate error linkStatus if err: plugin_result.extend( LinkStatus(url, url, -1, DS.Failed, name) for url in urls) # no debug for intentional errors if self.core.debug and not isinstance(e, Fail): self.core.print_exc() self.writeDebugReport(plugin.__name__, plugin=plugin) finally: if plugin:
def getProgress(self): """ Progress of the thread """ if self.active: active = self.active[0] return ProgressInfo(active.pluginname, active.name, active.getStatusName(), 0, self.progress, 100, self.owner, ProgressType.Addon)