summaryrefslogtreecommitdiffstats
path: root/pyload/plugin
diff options
context:
space:
mode:
authorGravatar Armin <Armin@Armin-PC.diedering.lan> 2015-04-09 20:11:11 +0200
committerGravatar Armin <Armin@Armin-PC.diedering.lan> 2015-04-09 20:11:11 +0200
commitf53d57b902b71708f05a3125872ec5d34ebe65b9 (patch)
tree2f8756396411a98331cb937e42ded87da2c9f253 /pyload/plugin
parentMerge remote-tracking branch 'origin/0.4.10' into 0.4.10 (diff)
downloadpyload-f53d57b902b71708f05a3125872ec5d34ebe65b9.tar.xz
fix: OboomCom and SmoozedCom with beaker >= v1.7.x
fix: run plugins this fix makes the plugin attribute "__name" obsolet
Diffstat (limited to 'pyload/plugin')
-rw-r--r--pyload/plugin/Account.py6
-rw-r--r--pyload/plugin/Addon.py4
-rw-r--r--pyload/plugin/OCR.py6
-rw-r--r--pyload/plugin/Plugin.py39
-rw-r--r--pyload/plugin/account/OboomCom.py14
-rw-r--r--pyload/plugin/account/SmoozedCom.py14
-rw-r--r--pyload/plugin/addon/DeleteFinished.py2
-rw-r--r--pyload/plugin/addon/ExtractArchive.py4
-rw-r--r--pyload/plugin/addon/MergeFiles.py2
-rw-r--r--pyload/plugin/addon/RestartFailed.py2
-rw-r--r--pyload/plugin/addon/UpdateManager.py8
-rw-r--r--pyload/plugin/internal/MultiHook.py8
-rw-r--r--pyload/plugin/internal/MultiHoster.py4
-rw-r--r--pyload/plugin/internal/SimpleHoster.py2
-rw-r--r--pyload/plugin/internal/XFSCrypter.py2
-rw-r--r--pyload/plugin/internal/XFSHoster.py2
16 files changed, 72 insertions, 47 deletions
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..d33cdd400 100644
--- a/pyload/plugin/Addon.py
+++ b/pyload/plugin/Addon.py
@@ -98,7 +98,7 @@ class Addon(Base):
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.core.config.getPlugin(self.__class__.__name__, "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..1c2091d66 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):
@@ -99,7 +100,7 @@ class Base(object):
:param value:
:return:
"""
- self.core.config.setPlugin(self.__name, option, value)
+ self.core.config.setPlugin(self.__class__.__name__, option, value)
#: Deprecated method
@@ -114,24 +115,24 @@ class Base(object):
:param option:
:return:
"""
- return self.core.config.getPlugin(self.__name, option)
+ return self.core.config.getPlugin(self.__class__.__name__, 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.__class__.__name__, key, value)
def store(self, key, value):
""" same as `setStorage` """
- self.core.db.setStorage(self.__name, key, value)
+ self.core.db.setStorage(self.__class__.__name__, 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.__class__.__name__, key) or default
+ return self.core.db.getStorage(self.__class__.__name__, key)
def retrieve(self, *args, **kwargs):
@@ -141,7 +142,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 +189,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 +210,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 +241,7 @@ class Plugin(Base):
def __call__(self):
- return self.__name
+ return self.__class__.__name__
def init(self):
@@ -277,7 +278,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 +452,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 +536,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/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/internal/MultiHook.py b/pyload/plugin/internal/MultiHook.py
index 5e828cd5e..c5fb21db5 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, type = self.core.pluginManager.findPlugin(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.pluginname = self.__class__.__name__
self.plugintype = type
- self.pluginmodule = self.core.pluginManager.loadModule(type, self.__name)
- self.pluginclass = getattr(self.pluginmodule, self.__name)
+ self.pluginmodule = self.core.pluginManager.loadModule(type, 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