def _decrypt(self, urls): """ Internal method to select decrypting method :param urls: List of urls/content :return: """ cls = self.__class__ # separate local and remote files content, urls = self.getLocalContent(urls) if has_method(cls, "decryptURLs"): self.setup() result = to_list(self.decryptURLs(urls)) elif has_method(cls, "decryptURL"): result = [] for url in urls: self.setup() result.extend(to_list(self.decryptURL(url))) elif has_method(cls, "decrypt"): self.logDebug("Deprecated .decrypt() method in Crypter plugin") result = [] for url in urls: self.pyfile = PyFileMockup(url, self.package) self.setup() self.decrypt(self.pyfile) result.extend(self.convertPackages()) else: if not has_method(cls, "decryptFile") or urls: self.logDebug( "No suited decrypting method was overwritten in plugin") result = [] if has_method(cls, "decryptFile"): for f, c in content: self.setup() result.extend(to_list(self.decryptFile(c))) try: if f.startswith("tmp_"): remove(f) except: pass return result
def _decrypt(self, urls): """ Internal method to select decrypting method :param urls: List of urls/content :return: """ cls = self.__class__ # separate local and remote files content, urls = self.getLocalContent(urls) if has_method(cls, "decryptURLs"): self.setup() result = to_list(self.decryptURLs(urls)) elif has_method(cls, "decryptURL"): result = [] for url in urls: self.setup() result.extend(to_list(self.decryptURL(url))) elif has_method(cls, "decrypt"): self.logDebug("Deprecated .decrypt() method in Crypter plugin") result = [] for url in urls: self.pyfile = PyFileMockup(url, self.package) self.setup() self.decrypt(self.pyfile) result.extend(self.convertPackages()) else: if not has_method(cls, "decryptFile") or urls: self.logDebug("No suited decrypting method was overwritten in plugin") result = [] if has_method(cls, "decryptFile"): for f, c in content: self.setup() result.extend(to_list(self.decryptFile(c))) try: if f.startswith("tmp_"): remove(f) except : pass return result
def decrypt(self, plugin, urls): self.m.log.debug("Pre decrypting %s" % plugin) klass = self.m.core.pluginManager.loadClass("crypter", plugin) # only decrypt files if has_method(klass, "decryptFile"): urls = klass.decrypt(urls) data, crypter = self.m.core.pluginManager.parseUrls(urls) return data return []
def activate(self): """ Used to activate the addon """ if has_method(self.__class__, "coreReady"): self.logDebug("Deprecated method .coreReady() use activate() instead") self.coreReady()
def run(self): """run method""" plugins = accumulate(self.data) crypter = {} # filter out crypter plugins for name in self.m.core.pluginManager.getPlugins("crypter"): if name in plugins: crypter[name] = plugins[name] del plugins[name] #directly write to database if self.pid > -1: for pluginname, urls in plugins.iteritems(): plugin = self.m.core.pluginManager.getPluginModule(pluginname) klass = self.m.core.pluginManager.getPluginClass(pluginname) if has_method(klass, "getInfo"): self.fetchForPlugin(pluginname, klass, urls, self.updateDB) self.m.core.files.save() elif has_method(plugin, "getInfo"): self.log.debug("Deprecated .getInfo() method on module level, use classmethod instead") self.fetchForPlugin(pluginname, plugin, urls, self.updateDB) self.m.core.files.save() else: #post the results for name, urls in crypter: #attach container content try: data = self.decrypt(name, urls) except: print_exc() self.m.log.error("Could not decrypt container.") data = [] accumulate(data, plugins) self.m.infoResults[self.rid] = {} for pluginname, urls in plugins.iteritems(): plugin = self.m.core.pluginManager.getPlugin(pluginname, True) klass = getattr(plugin, pluginname) if has_method(klass, "getInfo"): self.fetchForPlugin(pluginname, plugin, urls, self.updateResult, True) #force to process cache if self.cache: self.updateResult(pluginname, [], True) elif has_method(plugin, "getInfo"): self.log.debug("Deprecated .getInfo() method on module level, use staticmethod instead") self.fetchForPlugin(pluginname, plugin, urls, self.updateResult, True) #force to process cache if self.cache: self.updateResult(pluginname, [], True) else: #generate default result result = [(url, 0, 3, url) for url in urls] self.updateResult(pluginname, result, True) self.m.infoResults[self.rid]["ALL_INFO_FETCHED"] = {} self.m.timestamp = time() + 5 * 60
def run(self): """run method""" plugins = accumulate(self.data) crypter = {} # filter out crypter plugins for name in self.m.core.pluginManager.getPlugins("crypter"): if name in plugins: crypter[name] = plugins[name] del plugins[name] #directly write to database if self.pid > -1: for pluginname, urls in plugins.iteritems(): plugin = self.m.core.pluginManager.getPluginModule(pluginname) klass = self.m.core.pluginManager.getPluginClass(pluginname) if has_method(klass, "getInfo"): self.fetchForPlugin(pluginname, klass, urls, self.updateDB) self.m.core.files.save() elif has_method(plugin, "getInfo"): self.log.debug( "Deprecated .getInfo() method on module level, use classmethod instead" ) self.fetchForPlugin(pluginname, plugin, urls, self.updateDB) self.m.core.files.save() else: #post the results for name, urls in crypter: #attach container content try: data = self.decrypt(name, urls) except: print_exc() self.m.log.error("Could not decrypt container.") data = [] accumulate(data, plugins) self.m.infoResults[self.rid] = {} for pluginname, urls in plugins.iteritems(): plugin = self.m.core.pluginManager.getPlugin(pluginname, True) klass = getattr(plugin, pluginname) if has_method(klass, "getInfo"): self.fetchForPlugin(pluginname, plugin, urls, self.updateResult, True) #force to process cache if self.cache: self.updateResult(pluginname, [], True) elif has_method(plugin, "getInfo"): self.log.debug( "Deprecated .getInfo() method on module level, use staticmethod instead" ) self.fetchForPlugin(pluginname, plugin, urls, self.updateResult, True) #force to process cache if self.cache: self.updateResult(pluginname, [], True) else: #generate default result result = [(url, 0, 3, url) for url in urls] self.updateResult(pluginname, result, True) self.m.infoResults[self.rid]["ALL_INFO_FETCHED"] = {} self.m.timestamp = time() + 5 * 60
def activate(self): """ Used to activate the addon """ if has_method(self.__class__, "coreReady"): self.logDebug( "Deprecated method .coreReady() use activate() instead") self.coreReady()