diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-04-10 14:50:24 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-04-10 14:50:24 +0200 |
commit | c12cb8adcc0eef5ffc11762d85cae9f5ff8c2921 (patch) | |
tree | 3d2b5a37c18414714f68e721b52ca393dd7e75a9 | |
parent | [README] Update (2) (diff) | |
parent | added: configdata of deleted or outdated plugins are deletedfrom config (diff) | |
download | pyload-c12cb8adcc0eef5ffc11762d85cae9f5ff8c2921.tar.xz |
Merge pull request #2 from ardi69/0.4.10
makes the plugins runable
30 files changed, 150 insertions, 108 deletions
diff --git a/.gitignore b/.gitignore index 9e7a8c7df..5b222e058 100644 --- a/.gitignore +++ b/.gitignore @@ -79,3 +79,4 @@ eggs _build/ module/ paver-minilib.zip +/setup.sh diff --git a/pyload/__init__.py b/pyload/__init__.py index c89e55a3c..39f6c8bee 100644 --- a/pyload/__init__.py +++ b/pyload/__init__.py @@ -86,7 +86,7 @@ except IOError: if os.name == "posix": configdir = os.path.join(homedir, ".pyload-beta") else: - configdir = os.path.join(homedir, "pyload") + configdir = os.path.join(homedir, "pyload-beta") try: if not os.path.exists(configdir): diff --git a/pyload/config/Parser.py b/pyload/config/Parser.py index e21eaba9f..84c08f17c 100644 --- a/pyload/config/Parser.py +++ b/pyload/config/Parser.py @@ -295,6 +295,13 @@ class ConfigParser(object): self.save() + def removeDeletedPlugins(self, plugins): + for name in self.plugin.keys(): + if not name in plugins: + print "delete config " + name + del self.plugin[name] + + def getMetaData(self, section, option): """ get all config data for an option """ return self.config[section][option] diff --git a/pyload/config/Setup.py b/pyload/config/Setup.py index 7f5c0b0ed..3ce35bfe1 100644 --- a/pyload/config/Setup.py +++ b/pyload/config/Setup.py @@ -506,8 +506,8 @@ class SetupAssistant(object): pwlen = 8 while p1 != p2: sys.stdout.write(_("Password: ")) - p1 = getpass("") - + p1 = getpass("").strip("\n\r") + print("passwd:'%s'" % p1) if len(p1) < pwlen: print _("Password too short! Use at least %s symbols." % pwlen) continue @@ -516,7 +516,7 @@ class SetupAssistant(object): continue sys.stdout.write(_("Password (again): ")) - p2 = getpass("") + p2 = getpass("").strip("\n\r") if p1 == p2: return p1 diff --git a/pyload/manager/Account.py b/pyload/manager/Account.py index 2631e1c7d..12fc970c2 100644 --- a/pyload/manager/Account.py +++ b/pyload/manager/Account.py @@ -176,7 +176,7 @@ class AccountManager(object): if self.accounts[p]: p = self.getAccountPlugin(p) if p: - data[p.__name] = p.getAllAccounts(force) + data[p.__class__.__name__] = p.getAllAccounts(force) else: #@NOTE: When an account has been skipped, p is None data[p] = [] else: diff --git a/pyload/manager/Addon.py b/pyload/manager/Addon.py index 164068634..0bd51c943 100644 --- a/pyload/manager/Addon.py +++ b/pyload/manager/Addon.py @@ -71,7 +71,7 @@ class AddonManager(object): try: return func(*args) except Exception, e: - args[0].log.error(_("Error executing addon: %s") % e) + args[0].core.log.error(_("Error executing addon: %s") % e) if args[0].core.debug: traceback.print_exc() @@ -100,32 +100,32 @@ class AddonManager(object): def createIndex(self): plugins = [] - active = [] - deactive = [] - for pluginname in self.core.pluginManager.addonPlugins: - try: - # hookClass = getattr(plugin, plugin.__name) - if self.core.config.getPlugin(pluginname, "activated"): - pluginClass = self.core.pluginManager.loadClass("addon", pluginname) - if not pluginClass: - continue - - plugin = pluginClass(self.core, self) - plugins.append(plugin) - self.pluginMap[pluginClass.__name] = plugin - if plugin.isActivated(): - active.append(pluginClass.__name) - else: - deactive.append(pluginname) - - except Exception: - self.core.log.warning(_("Failed activating %(name)s") % {"name": pluginname}) - if self.core.debug: - traceback.print_exc() + for type in ("addon", "hook"): + active = [] + deactive = [] + for pluginname in getattr(self.core.pluginManager, "%sPlugins" % type): + try: + if self.core.config.getPlugin("%s_%s" % (pluginname, type), "activated"): + pluginClass = self.core.pluginManager.loadClass(type, pluginname) + if not pluginClass: + continue + + plugin = pluginClass(self.core, self) + plugins.append(plugin) + self.pluginMap[pluginClass.__name__] = plugin + if plugin.isActivated(): + active.append(pluginClass.__name__) + else: + deactive.append(pluginname) + + except Exception: + self.core.log.warning(_("Failed activating %(name)s") % {"name": pluginname}) + if self.core.debug or True: + traceback.print_exc() - self.core.log.info(_("Activated addons: %s") % ", ".join(sorted(active))) - self.core.log.info(_("Deactivated addons: %s") % ", ".join(sorted(deactive))) + self.core.log.info(_("Activated %ss: %s") % (type, ", ".join(sorted(active)))) + self.core.log.info(_("Deactivated %ss: %s") % (type, ", ".join(sorted(deactive)))) self.plugins = plugins @@ -141,7 +141,7 @@ class AddonManager(object): def activateAddon(self, pluginname): # check if already loaded for inst in self.plugins: - if inst.__name == pluginname: + if inst.__class__.__name__ == pluginname: return pluginClass = self.core.pluginManager.loadClass("addon", pluginname) @@ -153,14 +153,14 @@ class AddonManager(object): addon = pluginClass(self.core, self) self.plugins.append(addon) - self.pluginMap[pluginClass.__name] = addon + self.pluginMap[pluginClass.__name__] = addon addon.activate() def deactivateAddon(self, pluginname): for plugin in self.plugins: - if plugin.__name == pluginname: + if plugin.__class__.__name__ == pluginname: addon = plugin break else: @@ -174,7 +174,7 @@ class AddonManager(object): self.core.log.debug("Removed callback: %s" % self.core.scheduler.removeJob(addon.cb)) self.plugins.remove(addon) - del self.pluginMap[addon.__name] + del self.pluginMap[addon.__class__.__name__] @try_catch diff --git a/pyload/manager/Plugin.py b/pyload/manager/Plugin.py index 72fabb33a..222ed9c93 100644 --- a/pyload/manager/Plugin.py +++ b/pyload/manager/Plugin.py @@ -55,12 +55,15 @@ class PluginManager(object): sys.path.append(abspath("")) self.loadTypes() + + configs = [] for type in self.TYPES: self.plugins[type] = self.parse(type) setattr(self, "%sPlugins" % type, self.plugins[type]) + configs.extend("%s_%s" % (p, type) for p in self.plugins[type]) - self.plugins['addon'] = self.addonPlugins.update(self.hookPlugins) + self.core.config.removeDeletedPlugins(configs) self.core.log.debug("Created index of plugins") @@ -143,7 +146,7 @@ class PluginManager(object): # internals have no config if folder == "internal": - self.core.config.deleteConfig(name) + self.core.config.deleteConfig("internal") continue config = self.CONFIG.findall(content) @@ -161,7 +164,7 @@ class PluginManager(object): if folder not in ("account", "internal") and not [True for item in config if item[0] == "activated"]: config.insert(0, ["activated", "bool", "Activated", False if folder in ("addon", "hook") else True]) - self.core.config.addPluginConfig(name, config, desc) + self.core.config.addPluginConfig("%s_%s" % (name, folder), config, desc) except Exception: self.core.log.error("Invalid config in %s: %s" % (name, config)) @@ -171,7 +174,7 @@ class PluginManager(object): config = (["activated", "bool", "Activated", False],) try: - self.core.config.addPluginConfig(name, config, desc) + self.core.config.addPluginConfig("%s_%s" % (name, folder), config, desc) except Exception: self.core.log.error("Invalid config in %s: %s" % (name, config)) diff --git a/pyload/network/JsEngine.py b/pyload/network/JsEngine.py index 6ae90f299..c64e8c490 100644 --- a/pyload/network/JsEngine.py +++ b/pyload/network/JsEngine.py @@ -46,7 +46,7 @@ class JsEngine(object): elif isinstance(engine, basestring): engine_name = engine.lower() for E in ENGINES: - if E.__name == engine_name: #: doesn't check if E(NGINE) is available, just convert string to class + if E._name == engine_name: #: doesn't check if E(NGINE) is available, just convert string to class JSE = E break else: @@ -88,14 +88,14 @@ class JsEngine(object): if self.core.config.get("general", "debug"): if err: - self.core.log.debug(JSE.__name + ":", err) + self.core.log.debug(JSE._name + ":", err) engines = self.find() engines.remove(JSE) for E in engines: out, err = E.eval(script) res = err or out - self.core.log.debug(E.__name + ":", res) + self.core.log.debug(E._name + ":", res) results.append(res) if len(results) > 1 and len(uniqify(results)) > 1: @@ -107,7 +107,7 @@ class JsEngine(object): class AbstractEngine(object): """ JSE base class """ - __name = "" + _name = "" def __init__(self, force=False): @@ -123,7 +123,7 @@ class AbstractEngine(object): def find(cls): """ Check if the engine is available """ try: - __import__(cls.__name) + __import__(cls._name) except Exception: try: out, err = cls(True).eval("23+19") @@ -139,7 +139,7 @@ class AbstractEngine(object): def _eval(self, args): if not self.available: - return None, "JS Engine \"%s\" not found" % self.__name + return None, "JS Engine \"%s\" not found" % self._name try: p = subprocess.Popen(args, @@ -157,12 +157,12 @@ class AbstractEngine(object): class Pyv8Engine(AbstractEngine): - __name = "pyv8" + _name = "PyV8" def eval(self, script): if not self.available: - return None, "JS Engine \"%s\" not found" % self.__name + return None, "JS Engine \"%s\" not found" % self._name try: rt = PyV8.JSContext() @@ -176,11 +176,12 @@ class Pyv8Engine(AbstractEngine): class CommonEngine(AbstractEngine): - __name = "js" + _name = "js" def setup(self): - subprocess.Popen(["js", "-v"], bufsize=-1).communicate() + # subprocess.Popen(["js", "-v"], bufsize=-1).communicate() + pass def eval(self, script): @@ -191,7 +192,7 @@ class CommonEngine(AbstractEngine): class NodeEngine(AbstractEngine): - __name = "nodejs" + _name = "nodejs" def setup(self): @@ -206,7 +207,7 @@ class NodeEngine(AbstractEngine): class RhinoEngine(AbstractEngine): - __name = "rhino" + _name = "rhino" def setup(self): @@ -235,7 +236,7 @@ class RhinoEngine(AbstractEngine): class JscEngine(AbstractEngine): - __name = "javascriptcore" + _name = "javascriptcore" def setup(self): diff --git a/pyload/plugin/Account.py b/pyload/plugin/Account.py index b14615d3a..6a3eddc5b 100644 --- a/pyload/plugin/Account.py +++ b/pyload/plugin/Account.py @@ -197,7 +197,7 @@ class Account(Base): "maxtraffic" : None, "premium" : None, "timestamp" : 0, #: time this info was retrieved - "type" : self.__name} + "type" : self.__class__.__name__} def getAllAccounts(self, force=False): @@ -210,7 +210,7 @@ class Account(Base): if not user: return None - req = self.core.requestFactory.getRequest(self.__name, user) + req = self.core.requestFactory.getRequest(self.__class__.__name__, user) return req @@ -220,7 +220,7 @@ class Account(Base): if not user: return None - cj = self.core.requestFactory.getCookieJar(self.__name, user) + cj = self.core.requestFactory.getCookieJar(self.__class__.__name__, user) return cj diff --git a/pyload/plugin/Addon.py b/pyload/plugin/Addon.py index 14b5ee2a5..1f4730851 100644 --- a/pyload/plugin/Addon.py +++ b/pyload/plugin/Addon.py @@ -78,7 +78,7 @@ class Addon(Base): def initPeriodical(self, delay=0, threaded=False): - self.cb = self.core.scheduler.addJob(max(0, delay), self._periodical, args=[threaded], threaded=threaded) + self.cb = self.core.scheduler.addJob(max(0, delay), self._periodical, [threaded], threaded=threaded) def _periodical(self, threaded): @@ -94,11 +94,11 @@ class Addon(Base): if self.core.debug: print_exc() - self.cb = self.core.scheduler.addJob(self.interval, self._periodical, threaded=threaded) + self.cb = self.core.scheduler.addJob(self.interval, self._periodical, [threaded], threaded=threaded) def __repr__(self): - return "<Addon %s>" % self.__name + return "<Addon %s>" % self.__class__.__name__ def setup(self): @@ -117,7 +117,7 @@ class Addon(Base): def isActivated(self): """ checks if addon is activated""" - return self.core.config.getPlugin(self.__name, "activated") + return self.getConfig("activated") # Event methods - overwrite these if needed diff --git a/pyload/plugin/OCR.py b/pyload/plugin/OCR.py index 109dd1843..01ba6d534 100644 --- a/pyload/plugin/OCR.py +++ b/pyload/plugin/OCR.py @@ -60,11 +60,11 @@ class OCR(Base): def run_tesser(self, subset=False, digits=True, lowercase=True, uppercase=True): #tmpTif = tempfile.NamedTemporaryFile(suffix=".tif") try: - tmpTif = open(fs_join("tmp", "tmpTif_%s.tif" % self.__name), "wb") + tmpTif = open(fs_join("tmp", "tmpTif_%s.tif" % self.__class__.__name__), "wb") tmpTif.close() #tmpTxt = tempfile.NamedTemporaryFile(suffix=".txt") - tmpTxt = open(fs_join("tmp", "tmpTxt_%s.txt" % self.__name), "wb") + tmpTxt = open(fs_join("tmp", "tmpTxt_%s.txt" % self.__class__.__name__), "wb") tmpTxt.close() except IOError, e: @@ -83,7 +83,7 @@ class OCR(Base): if subset and (digits or lowercase or uppercase): #tmpSub = tempfile.NamedTemporaryFile(suffix=".subset") - with open(fs_join("tmp", "tmpSub_%s.subset" % self.__name), "wb") as tmpSub: + with open(fs_join("tmp", "tmpSub_%s.subset" % self.__class__.__name__), "wb") as tmpSub: tmpSub.write("tessedit_char_whitelist ") if digits: diff --git a/pyload/plugin/Plugin.py b/pyload/plugin/Plugin.py index e136bfc29..486dbeb0f 100644 --- a/pyload/plugin/Plugin.py +++ b/pyload/plugin/Plugin.py @@ -6,6 +6,7 @@ from time import time, sleep from random import randint import os +import re from os import remove, makedirs, chmod, stat from os.path import exists, join @@ -18,7 +19,7 @@ from itertools import islice from traceback import print_exc from urlparse import urlparse -from pyload.utils import fs_decode, fs_encode, safe_filename, fs_join +from pyload.utils import fs_decode, fs_encode, safe_filename, fs_join, encode def chunks(iterable, size): @@ -62,7 +63,7 @@ class Base(object): def _log(self, type, args): msg = " | ".join([encode(a).strip() for a in args if a]) logger = getattr(self.core.log, type) - logger("%s: %s" % (self.__name, msg or _("%s MARK" % type.upper()))) + logger("%s: %s" % (self.__class__.__name__, msg or _("%s MARK" % type.upper()))) def logDebug(self, *args): @@ -86,6 +87,10 @@ class Base(object): return self._log("critical", args) + def getPluginConfSection(self): + return "%s_%s" % (self.__class__.__name__, getattr(self, "_%s__type" % self.__class__.__name__)) + + #: Deprecated method def setConf(self, option, value): """ see `setConfig` """ @@ -99,7 +104,7 @@ class Base(object): :param value: :return: """ - self.core.config.setPlugin(self.__name, option, value) + self.core.config.setPlugin(self.getPluginConfSection(), option, value) #: Deprecated method @@ -114,24 +119,24 @@ class Base(object): :param option: :return: """ - return self.core.config.getPlugin(self.__name, option) + return self.core.config.getPlugin(self.getPluginConfSection(), option) def setStorage(self, key, value): """ Saves a value persistently to the database """ - self.core.db.setStorage(self.__name, key, value) + self.core.db.setStorage(self.getPluginConfSection(), key, value) def store(self, key, value): """ same as `setStorage` """ - self.core.db.setStorage(self.__name, key, value) + self.core.db.setStorage(self.getPluginConfSection(), key, value) def getStorage(self, key=None, default=None): """ Retrieves saved value or dict of all saved entries if key is None """ if key: - return self.core.db.getStorage(self.__name, key) or default - return self.core.db.getStorage(self.__name, key) + return self.core.db.getStorage(self.getPluginConfSection(), key) or default + return self.core.db.getStorage(self.getPluginConfSection(), key) def retrieve(self, *args, **kwargs): @@ -141,7 +146,7 @@ class Base(object): def delStorage(self, key): """ Delete entry in db """ - self.core.db.delStorage(self.__name, key) + self.core.db.delStorage(self.__class__.__name__, key) class Plugin(Base): @@ -188,7 +193,7 @@ class Plugin(Base): self.ocr = None #: account handler instance, see :py:class:`Account` - self.account = pyfile.m.core.accountManager.getAccountPlugin(self.__name) + self.account = pyfile.m.core.accountManager.getAccountPlugin(self.__class__.__name__) #: premium status self.premium = False @@ -209,7 +214,7 @@ class Plugin(Base): #: premium status self.premium = self.account.isPremium(self.user) else: - self.req = pyfile.m.core.requestFactory.getRequest(self.__name) + self.req = pyfile.m.core.requestFactory.getRequest(self.__class__.__name__) #: associated pyfile instance, see `PyFile` self.pyfile = pyfile @@ -240,7 +245,7 @@ class Plugin(Base): def __call__(self): - return self.__name + return self.__class__.__name__ def init(self): @@ -277,7 +282,7 @@ class Plugin(Base): def resetAccount(self): """ dont use account and retry download """ self.account = None - self.req = self.core.requestFactory.getRequest(self.__name) + self.req = self.core.requestFactory.getRequest(self.__class__.__name__) self.retry() @@ -451,13 +456,13 @@ class Plugin(Base): id = ("%.2f" % time())[-6:].replace(".", "") - with open(join("tmp", "tmpCaptcha_%s_%s.%s" % (self.__name, id, imgtype)), "wb") as tmpCaptcha: + with open(join("tmp", "tmpCaptcha_%s_%s.%s" % (self.__class__.__name__, id, imgtype)), "wb") as tmpCaptcha: tmpCaptcha.write(img) - has_plugin = self.__name in self.core.pluginManager.ocrPlugins + has_plugin = self.__class__.__name__ in self.core.pluginManager.ocrPlugins if self.core.captcha: - Ocr = self.core.pluginManager.loadClass("ocr", self.__name) + Ocr = self.core.pluginManager.loadClass("ocr", self.__class__.__name__) else: Ocr = None @@ -535,10 +540,10 @@ class Plugin(Base): from inspect import currentframe frame = currentframe() - framefile = fs_join("tmp", self.__name, "%s_line%s.dump.html" % (frame.f_back.f_code.co_name, frame.f_back.f_lineno)) + framefile = fs_join("tmp", self.__class__.__name__, "%s_line%s.dump.html" % (frame.f_back.f_code.co_name, frame.f_back.f_lineno)) try: - if not exists(join("tmp", self.__name)): - makedirs(join("tmp", self.__name)) + if not exists(join("tmp", self.__class__.__name__)): + makedirs(join("tmp", self.__class__.__name__)) with open(framefile, "wb") as f: del frame #: delete the frame or it wont be cleaned diff --git a/pyload/plugin/account/OboomCom.py b/pyload/plugin/account/OboomCom.py index 7b73c38fa..0712cbc37 100644 --- a/pyload/plugin/account/OboomCom.py +++ b/pyload/plugin/account/OboomCom.py @@ -2,7 +2,19 @@ import time -from beaker.crypto.pbkdf2 import PBKDF2 +try: + from beaker.crypto.pbkdf2 import PBKDF2 +except: + from beaker.crypto.pbkdf2 import pbkdf2 + from binascii import b2a_hex + class PBKDF2(object): + def __init__(self, passphrase, salt, iterations=1000): + self.passphrase = passphrase + self.salt = salt + self.iterations = iterations + + def hexread(self, octets): + return b2a_hex(pbkdf2(self.passphrase, self.salt, self.iterations, octets)) from pyload.utils import json_loads from pyload.plugin.Account import Account diff --git a/pyload/plugin/account/SmoozedCom.py b/pyload/plugin/account/SmoozedCom.py index 54cd94fbf..ffe7142cf 100644 --- a/pyload/plugin/account/SmoozedCom.py +++ b/pyload/plugin/account/SmoozedCom.py @@ -3,7 +3,19 @@ import hashlib import time -from beaker.crypto.pbkdf2 import PBKDF2 +try: + from beaker.crypto.pbkdf2 import PBKDF2 +except: + from beaker.crypto.pbkdf2 import pbkdf2 + from binascii import b2a_hex + class PBKDF2(object): + def __init__(self, passphrase, salt, iterations=1000): + self.passphrase = passphrase + self.salt = salt + self.iterations = iterations + + def hexread(self, octets): + return b2a_hex(pbkdf2(self.passphrase, self.salt, self.iterations, octets)) from pyload.utils import json_loads from pyload.plugin.Account import Account diff --git a/pyload/plugin/addon/ClickAndLoad.py b/pyload/plugin/addon/ClickAndLoad.py index 708f7da0b..1e420fa8e 100644 --- a/pyload/plugin/addon/ClickAndLoad.py +++ b/pyload/plugin/addon/ClickAndLoad.py @@ -37,11 +37,11 @@ class ClickAndLoad(Addon): def activate(self): - if not self.config['webinterface']['activated']: + if not self.core.config['webui']['activated']: return ip = "" if self.getConfig('extern') else "127.0.0.1" - webport = self.config['webinterface']['port'] + webport = self.core.config['webui']['port'] cnlport = self.getConfig('port') self.proxy(ip, webport, cnlport) diff --git a/pyload/plugin/addon/DeleteFinished.py b/pyload/plugin/addon/DeleteFinished.py index 2349503f6..7e47a8728 100644 --- a/pyload/plugin/addon/DeleteFinished.py +++ b/pyload/plugin/addon/DeleteFinished.py @@ -52,7 +52,7 @@ class DeleteFinished(Addon): def activate(self): self.info['sleep'] = True # interval = self.getConfig('interval') - # self.pluginConfigChanged(self.__name, 'interval', interval) + # self.pluginConfigChanged(self.__class__.__name__, 'interval', interval) self.interval = max(self.MIN_CHECK_INTERVAL, self.getConfig('interval') * 60 * 60) self.addEvent('packageFinished', self.wakeup) self.initPeriodical() diff --git a/pyload/plugin/addon/ExtractArchive.py b/pyload/plugin/addon/ExtractArchive.py index 369be11bb..c5b3b6993 100644 --- a/pyload/plugin/addon/ExtractArchive.py +++ b/pyload/plugin/addon/ExtractArchive.py @@ -173,7 +173,7 @@ class ExtractArchive(Addon): print_exc() if self.extractors: - self.logInfo(_("Activated") + " " + "|".join("%s %s" % (Extractor.__name,Extractor.VERSION) for Extractor in self.extractors)) + self.logInfo(_("Activated") + " " + "|".join("%s %s" % (Extractor.__name__,Extractor.VERSION) for Extractor in self.extractors)) self.extractQueued() #: Resume unfinished extractions else: self.logInfo(_("No Extract plugins activated")) @@ -288,7 +288,7 @@ class ExtractArchive(Addon): for Extractor in self.extractors: targets = Extractor.getTargets(files_ids) if targets: - self.logDebug("Targets for %s: %s" % (Extractor.__name, targets)) + self.logDebug("Targets for %s: %s" % (Extractor.__class__.__name__, targets)) matched = True for fname, fid, fout in targets: diff --git a/pyload/plugin/addon/MergeFiles.py b/pyload/plugin/addon/MergeFiles.py index 87775bea2..a0298052b 100644 --- a/pyload/plugin/addon/MergeFiles.py +++ b/pyload/plugin/addon/MergeFiles.py @@ -46,7 +46,7 @@ class MergeFiles(Addon): for name, file_list in files.iteritems(): self.logInfo(_("Starting merging of"), name) - final_file = open(fs_join(download_folder, name), "wb") + with open(fs_join(download_folder, name), "wb") as final_file: for splitted_file in file_list: self.logDebug("Merging part", splitted_file) diff --git a/pyload/plugin/addon/RestartFailed.py b/pyload/plugin/addon/RestartFailed.py index eaa86ebcb..695ebb154 100644 --- a/pyload/plugin/addon/RestartFailed.py +++ b/pyload/plugin/addon/RestartFailed.py @@ -38,6 +38,6 @@ class RestartFailed(Addon): def activate(self): - # self.pluginConfigChanged(self.__name, "interval", self.getConfig('interval')) + # self.pluginConfigChanged(self.__class__.__name__, "interval", self.getConfig('interval')) self.interval = max(self.MIN_CHECK_INTERVAL, self.getConfig('interval') * 60) self.initPeriodical() diff --git a/pyload/plugin/addon/UpdateManager.py b/pyload/plugin/addon/UpdateManager.py index a2b26b618..41a1d7f2c 100644 --- a/pyload/plugin/addon/UpdateManager.py +++ b/pyload/plugin/addon/UpdateManager.py @@ -83,15 +83,15 @@ class UpdateManager(Addon): def autoreloadPlugins(self): """ reload and reindex all modified plugins """ modules = filter( - lambda m: m and (m.__name.startswith("module.plugins.") or - m.__name.startswith("userplugins.")) and - m.__name.count(".") >= 2, sys.modules.itervalues() + lambda m: m and (m.__name__.startswith("module.plugins.") or + m.__name__.startswith("userplugins.")) and + m.__name__.count(".") >= 2, sys.modules.itervalues() ) reloads = [] for m in modules: - root, type, name = m.__name.rsplit(".", 2) + root, type, name = m.__name__.rsplit(".", 2) id = (type, name) if type in self.core.pluginManager.plugins: f = m.__file__.replace(".pyc", ".py") diff --git a/pyload/plugin/hook/XFileSharingPro.py b/pyload/plugin/hook/XFileSharingPro.py index 9ded9cd53..1f3a27fd5 100644 --- a/pyload/plugin/hook/XFileSharingPro.py +++ b/pyload/plugin/hook/XFileSharingPro.py @@ -50,7 +50,7 @@ class XFileSharingPro(Hook): def loadPattern(self): - use_builtin_list = self.getConfig('use_builtin_list') + use_builtin_list = self.getConfig("use_builtin_list") for type in ("hoster", "crypter"): every_plugin = not self.getConfig('use_%s_list' % type) diff --git a/pyload/plugin/hoster/OverLoadMe.py b/pyload/plugin/hoster/OverLoadMe.py index ca365549a..ad15f60df 100644 --- a/pyload/plugin/hoster/OverLoadMe.py +++ b/pyload/plugin/hoster/OverLoadMe.py @@ -47,6 +47,6 @@ class OverLoadMe(MultiHoster): pyfile.size = parseFileSize(data['filesize']) http_repl = ["http://", "https://"] - self.link = data['downloadlink'].replace(*http_repl if self.getConfig('ssl') else *http_repl[::-1]) + self.link = data['downloadlink'].replace(*http_repl if self.getConfig('ssl') else http_repl[::-1]) diff --git a/pyload/plugin/internal/MultiHook.py b/pyload/plugin/internal/MultiHook.py index 5e828cd5e..acf17f6dc 100644 --- a/pyload/plugin/internal/MultiHook.py +++ b/pyload/plugin/internal/MultiHook.py @@ -68,16 +68,16 @@ class MultiHook(Hook): def _initPlugin(self): - plugin, type = self.core.pluginManager.findPlugin(self.__name) + plugin = self.core.pluginManager.findPlugin("hoster", self.__class__.__name__) if not plugin: self.logWarning("Hook plugin will be deactivated due missing plugin reference") self.setConfig('activated', False) else: - self.pluginname = self.__name - self.plugintype = type - self.pluginmodule = self.core.pluginManager.loadModule(type, self.__name) - self.pluginclass = getattr(self.pluginmodule, self.__name) + self.pluginname = self.__class__.__name__ + self.plugintype = "hoster" + self.pluginmodule = self.core.pluginManager.loadModule("hoster", self.__class__.__name__) + self.pluginclass = getattr(self.pluginmodule, self.__class__.__name__) def loadAccount(self): diff --git a/pyload/plugin/internal/MultiHoster.py b/pyload/plugin/internal/MultiHoster.py index a38da9bdb..a7e74b2ff 100644 --- a/pyload/plugin/internal/MultiHoster.py +++ b/pyload/plugin/internal/MultiHoster.py @@ -86,8 +86,8 @@ class MultiHoster(SimpleHoster): self.retryFree() elif self.getConfig('revertfailed', True) \ - and "new_module" in self.core.pluginManager.hosterPlugins[self.__name]: - hdict = self.core.pluginManager.hosterPlugins[self.__name] + and "new_module" in self.core.pluginManager.hosterPlugins[self.__class__.__name__]: + hdict = self.core.pluginManager.hosterPlugins[self.__class__.__name__] tmp_module = hdict['new_module'] tmp_name = hdict['new_name'] diff --git a/pyload/plugin/internal/SimpleHoster.py b/pyload/plugin/internal/SimpleHoster.py index d07eca2a1..60f13324f 100644 --- a/pyload/plugin/internal/SimpleHoster.py +++ b/pyload/plugin/internal/SimpleHoster.py @@ -437,7 +437,7 @@ class SimpleHoster(Hoster): set_cookies(self.req.cj, self.COOKIES) if (self.MULTI_HOSTER - and (self.__pattern != self.core.pluginManager.hosterPlugins[self.__name]['pattern'] + and (self.__pattern != self.core.pluginManager.hosterPlugins[self.__class__.__name__]['pattern'] or re.match(self.__pattern, self.pyfile.url) is None)): self.multihost = True return diff --git a/pyload/plugin/internal/XFSCrypter.py b/pyload/plugin/internal/XFSCrypter.py index 44b4ed724..6a3f09e55 100644 --- a/pyload/plugin/internal/XFSCrypter.py +++ b/pyload/plugin/internal/XFSCrypter.py @@ -31,7 +31,7 @@ class XFSCrypter(SimpleCrypter): if self.account: account = self.account else: - account_name = (self.__name + ".py").replace("Folder.py", "").replace(".py", "") + account_name = (self.__class__.__name__ + ".py").replace("Folder.py", "").replace(".py", "") account = self.pyfile.m.core.accountManager.getAccountPlugin(account_name) if account and hasattr(account, "HOSTER_DOMAIN") and account.HOSTER_DOMAIN: diff --git a/pyload/plugin/internal/XFSHoster.py b/pyload/plugin/internal/XFSHoster.py index 05b26bebe..e87b6b0ee 100644 --- a/pyload/plugin/internal/XFSHoster.py +++ b/pyload/plugin/internal/XFSHoster.py @@ -64,7 +64,7 @@ class XFSHoster(SimpleHoster): if self.account: account = self.account else: - account = self.pyfile.m.core.accountManager.getAccountPlugin(self.__name) + account = self.pyfile.m.core.accountManager.getAccountPlugin(self.__class__.__name__) if account and hasattr(account, "HOSTER_DOMAIN") and account.HOSTER_DOMAIN: self.HOSTER_DOMAIN = account.HOSTER_DOMAIN diff --git a/pyload/utils/__init__.py b/pyload/utils/__init__.py index 46b375e7a..44bff909c 100644 --- a/pyload/utils/__init__.py +++ b/pyload/utils/__init__.py @@ -265,3 +265,4 @@ def load_translation(name, locale, default="en"): else: translation.install(True) return translation + diff --git a/pyload/webui/app/pyloadweb.py b/pyload/webui/app/pyloadweb.py index d7604918b..d71d0d306 100644 --- a/pyload/webui/app/pyloadweb.py +++ b/pyload/webui/app/pyloadweb.py @@ -94,12 +94,12 @@ def server_min(theme, file): def server_js(theme, file): response.headers['Content-Type'] = "text/javascript; charset=UTF-8" - if "/render/" in file or ".render." in file: + if "/render/" in file or ".render." in file or True: response.headers['Expires'] = time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(time.time() + 24 * 7 * 60 * 60)) response.headers['Cache-control'] = "public" - path = join(theme, file) + path = "/".join((theme, file)) return env.get_template(path).render() else: return server_static(theme, file) diff --git a/pyload/webui/app/utils.py b/pyload/webui/app/utils.py index fd0e14cfa..4a431493b 100644 --- a/pyload/webui/app/utils.py +++ b/pyload/webui/app/utils.py @@ -12,7 +12,7 @@ from pyload.api import has_permission, PERMS, ROLE def render_to_response(file, args={}, proc=[]): for p in proc: args.update(p()) - path = join(THEME, "tml", file) + path = "tml/" + file return env.get_template(path).render(**args) |