diff options
author | Armin <Armin@Armin-PC.diedering.lan> | 2015-04-20 22:24:43 +0200 |
---|---|---|
committer | Armin <Armin@Armin-PC.diedering.lan> | 2015-04-20 22:24:43 +0200 |
commit | 919b6dacac69459c64239c3d48ccc435a18b049c (patch) | |
tree | af4b6fb3c49b1f79960a810c3963681f8be86b3f | |
parent | add log warnings by using of deprecated features (diff) | |
download | pyload-919b6dacac69459c64239c3d48ccc435a18b049c.tar.xz |
Improve getClassName
-rw-r--r-- | pyload/plugin/Account.py | 6 | ||||
-rw-r--r-- | pyload/plugin/Addon.py | 2 | ||||
-rw-r--r-- | pyload/plugin/OCR.py | 6 | ||||
-rw-r--r-- | pyload/plugin/Plugin.py | 28 | ||||
-rw-r--r-- | pyload/plugin/addon/DeleteFinished.py | 2 | ||||
-rw-r--r-- | pyload/plugin/addon/RestartFailed.py | 2 | ||||
-rw-r--r-- | pyload/plugin/crypter/XFileSharingPro.py | 4 | ||||
-rw-r--r-- | pyload/plugin/hook/BypassCaptcha.py | 8 | ||||
-rw-r--r-- | pyload/plugin/hook/CaptchaBrotherhood.py | 4 | ||||
-rw-r--r-- | pyload/plugin/hook/DeathByCaptcha.py | 4 | ||||
-rw-r--r-- | pyload/plugin/hook/ImageTyperz.py | 6 | ||||
-rw-r--r-- | pyload/plugin/hoster/FileserveCom.py | 4 | ||||
-rw-r--r-- | pyload/plugin/hoster/NoPremiumPl.py | 2 | ||||
-rw-r--r-- | pyload/plugin/hoster/RapideoPl.py | 2 | ||||
-rw-r--r-- | pyload/plugin/hoster/XFileSharingPro.py | 4 | ||||
-rw-r--r-- | pyload/plugin/hoster/Xdcc.py | 2 | ||||
-rw-r--r-- | pyload/plugin/internal/MultiHook.py | 2 | ||||
-rw-r--r-- | pyload/plugin/internal/MultiHoster.py | 4 | ||||
-rw-r--r-- | pyload/plugin/internal/SimpleHoster.py | 4 | ||||
-rw-r--r-- | pyload/plugin/internal/XFSCrypter.py | 2 | ||||
-rw-r--r-- | pyload/plugin/internal/XFSHoster.py | 2 |
21 files changed, 50 insertions, 50 deletions
diff --git a/pyload/plugin/Account.py b/pyload/plugin/Account.py index c46eae5e3..73554cc39 100644 --- a/pyload/plugin/Account.py +++ b/pyload/plugin/Account.py @@ -196,7 +196,7 @@ class Account(Base): "maxtraffic" : None, "premium" : None, "timestamp" : 0, #: time this info was retrieved - "type" : self.__class__.__name__} + "type" : self.getClassName()} def getAllAccounts(self, force=False): @@ -209,7 +209,7 @@ class Account(Base): if not user: return None - req = self.core.requestFactory.getRequest(self.__class__.__name__, user) + req = self.core.requestFactory.getRequest(self.getClassName(), user) return req @@ -219,7 +219,7 @@ class Account(Base): if not user: return None - cj = self.core.requestFactory.getCookieJar(self.__class__.__name__, user) + cj = self.core.requestFactory.getCookieJar(self.getClassName(), user) return cj diff --git a/pyload/plugin/Addon.py b/pyload/plugin/Addon.py index e66c5999e..a43f2fd70 100644 --- a/pyload/plugin/Addon.py +++ b/pyload/plugin/Addon.py @@ -100,7 +100,7 @@ class Addon(Base): def __repr__(self): - return "<Addon %s>" % self.__class__.__name__ + return "<Addon %s>" % self.getClassName() def setup(self): diff --git a/pyload/plugin/OCR.py b/pyload/plugin/OCR.py index df5eeea1f..126283f01 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, pagesegmode=None): # tmpTif = tempfile.NamedTemporaryFile(suffix=".tif") try: - tmpTif = open(fs_join("tmp", "tmpTif_%s.tif" % self.__class__.__name__), "wb") + tmpTif = open(fs_join("tmp", "tmpTif_%s.tif" % self.getClassName()), "wb") tmpTif.close() # tmpTxt = tempfile.NamedTemporaryFile(suffix=".txt") - tmpTxt = open(fs_join("tmp", "tmpTxt_%s.txt" % self.__class__.__name__), "wb") + tmpTxt = open(fs_join("tmp", "tmpTxt_%s.txt" % self.getClassName()), "wb") tmpTxt.close() except IOError, e: @@ -86,7 +86,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.__class__.__name__), "wb") as tmpSub: + with open(fs_join("tmp", "tmpSub_%s.subset" % self.getClassName()), "wb") as tmpSub: tmpSub.write("tessedit_char_whitelist ") if digits: diff --git a/pyload/plugin/Plugin.py b/pyload/plugin/Plugin.py index 54963447c..369d040fb 100644 --- a/pyload/plugin/Plugin.py +++ b/pyload/plugin/Plugin.py @@ -66,7 +66,7 @@ class Base(object): def _log(self, type, args): msg = " | ".join([encode(str(a)).strip() for a in args if a]) logger = getattr(self.core.log, type) - logger("%s: %s" % (self.__class__.__name__, msg or _("%s MARK" % type.upper()))) + logger("%s: %s" % (self.getClassName(), msg or _("%s MARK" % type.upper()))) def logDebug(self, *args): @@ -91,7 +91,7 @@ class Base(object): def getPluginType(self): - return getattr(self, "_%s__type" % self.__class__.__name__) + return getattr(self, "_%s__type" % self.getClassName()) @classmethod @@ -100,7 +100,7 @@ class Base(object): def getPluginConfSection(self): - return "%s_%s" % (self.__class__.__name__, getattr(self, "_%s__type" % self.__class__.__name__)) + return "%s_%s" % (self.getClassName(), getattr(self, "_%s__type" % self.getClassName())) #: Deprecated method @@ -160,7 +160,7 @@ class Base(object): def delStorage(self, key): """ Delete entry in db """ - self.core.db.delStorage(self.__class__.__name__, key) + self.core.db.delStorage(self.getClassName(), key) class Plugin(Base): @@ -206,7 +206,7 @@ class Plugin(Base): self.ocr = None #: account handler instance, see :py:class:`Account` - self.account = pyfile.m.core.accountManager.getAccountPlugin(self.__class__.__name__) + self.account = pyfile.m.core.accountManager.getAccountPlugin(self.getClassName()) #: premium status self.premium = False @@ -227,7 +227,7 @@ class Plugin(Base): #: premium status self.premium = self.account.isPremium(self.user) else: - self.req = pyfile.m.core.requestFactory.getRequest(self.__class__.__name__) + self.req = pyfile.m.core.requestFactory.getRequest(self.getClassName()) #: associated pyfile instance, see `PyFile` self.pyfile = pyfile @@ -258,7 +258,7 @@ class Plugin(Base): def __call__(self): - return self.__class__.__name__ + return self.getClassName() def init(self): @@ -295,7 +295,7 @@ class Plugin(Base): def resetAccount(self): """ dont use account and retry download """ self.account = None - self.req = self.core.requestFactory.getRequest(self.__class__.__name__) + self.req = self.core.requestFactory.getRequest(self.getClassName()) self.retry() @@ -469,13 +469,13 @@ class Plugin(Base): id = ("%.2f" % time())[-6:].replace(".", "") - with open(join("tmp", "tmpCaptcha_%s_%s.%s" % (self.__class__.__name__, id, imgtype)), "wb") as tmpCaptcha: + with open(join("tmp", "tmpCaptcha_%s_%s.%s" % (self.getClassName(), id, imgtype)), "wb") as tmpCaptcha: tmpCaptcha.write(img) - has_plugin = self.__class__.__name__ in self.core.pluginManager.ocrPlugins + has_plugin = self.getClassName() in self.core.pluginManager.ocrPlugins if self.core.captcha: - Ocr = self.core.pluginManager.loadClass("ocr", self.__class__.__name__) + Ocr = self.core.pluginManager.loadClass("ocr", self.getClassName()) else: Ocr = None @@ -553,10 +553,10 @@ class Plugin(Base): from inspect import currentframe frame = currentframe() - framefile = fs_join("tmp", self.__class__.__name__, "%s_line%s.dump.html" % (frame.f_back.f_code.co_name, frame.f_back.f_lineno)) + framefile = fs_join("tmp", self.getClassName(), "%s_line%s.dump.html" % (frame.f_back.f_code.co_name, frame.f_back.f_lineno)) try: - if not exists(join("tmp", self.__class__.__name__)): - makedirs(join("tmp", self.__class__.__name__)) + if not exists(join("tmp", self.getClassName())): + makedirs(join("tmp", self.getClassName())) with open(framefile, "wb") as f: del frame #: delete the frame or it wont be cleaned diff --git a/pyload/plugin/addon/DeleteFinished.py b/pyload/plugin/addon/DeleteFinished.py index b9368a642..8fe0b1497 100644 --- a/pyload/plugin/addon/DeleteFinished.py +++ b/pyload/plugin/addon/DeleteFinished.py @@ -53,7 +53,7 @@ class DeleteFinished(Addon): def activate(self): self.info['sleep'] = True # interval = self.getConfig('interval') - # self.pluginConfigChanged(self.__class__.__name__, 'interval', interval) + # self.pluginConfigChanged(self.getClassName(), '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/RestartFailed.py b/pyload/plugin/addon/RestartFailed.py index 695ebb154..8a3a36fe1 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.__class__.__name__, "interval", self.getConfig('interval')) + # self.pluginConfigChanged(self.getClassName(), "interval", self.getConfig('interval')) self.interval = max(self.MIN_CHECK_INTERVAL, self.getConfig('interval') * 60) self.initPeriodical() diff --git a/pyload/plugin/crypter/XFileSharingPro.py b/pyload/plugin/crypter/XFileSharingPro.py index c83c0c67e..b78d83262 100644 --- a/pyload/plugin/crypter/XFileSharingPro.py +++ b/pyload/plugin/crypter/XFileSharingPro.py @@ -22,13 +22,13 @@ class XFileSharingPro(XFSCrypter): def _log(self, type, args): msg = " | ".join(str(a).strip() for a in args if a) logger = getattr(self.log, type) - logger("%s: %s: %s" % (self.__class__.__name__, self.HOSTER_NAME, msg or _("%s MARK" % type.upper()))) + logger("%s: %s: %s" % (self.getClassName(), self.HOSTER_NAME, msg or _("%s MARK" % type.upper()))) def init(self): super(XFileSharingPro, self).init() - self.__pattern = self.core.pluginManager.crypterPlugins[self.__class__.__name__]['pattern'] + self.__pattern = self.core.pluginManager.crypterPlugins[self.getClassName()]['pattern'] self.HOSTER_DOMAIN = re.match(self.__pattern, self.pyfile.url).group("DOMAIN").lower() self.HOSTER_NAME = "".join(part.capitalize() for part in re.split(r'(\.|\d+)', self.HOSTER_DOMAIN) if part != '.') diff --git a/pyload/plugin/hook/BypassCaptcha.py b/pyload/plugin/hook/BypassCaptcha.py index e3fae426e..545ec5e31 100644 --- a/pyload/plugin/hook/BypassCaptcha.py +++ b/pyload/plugin/hook/BypassCaptcha.py @@ -104,21 +104,21 @@ class BypassCaptcha(Hook): if self.getCredits() > 0: task.handler.append(self) - task.data['service'] = self.__class__.__name__ + task.data['service'] = self.getClassName() task.setWaiting(100) self._processCaptcha(task) else: - self.logInfo(_("Your %s account has not enough credits") % self.__class__.__name__) + self.logInfo(_("Your %s account has not enough credits") % self.getClassName()) def captchaCorrect(self, task): - if task.data['service'] == self.__class__.__name__ and "ticket" in task.data: + if task.data['service'] == self.getClassName() and "ticket" in task.data: self.respond(task.data['ticket'], True) def captchaInvalid(self, task): - if task.data['service'] == self.__class__.__name__ and "ticket" in task.data: + if task.data['service'] == self.getClassName() and "ticket" in task.data: self.respond(task.data['ticket'], False) diff --git a/pyload/plugin/hook/CaptchaBrotherhood.py b/pyload/plugin/hook/CaptchaBrotherhood.py index 15338b0af..97e1ff25f 100644 --- a/pyload/plugin/hook/CaptchaBrotherhood.py +++ b/pyload/plugin/hook/CaptchaBrotherhood.py @@ -147,7 +147,7 @@ class CaptchaBrotherhood(Hook): if self.getCredits() > 10: task.handler.append(self) - task.data['service'] = self.__class__.__name__ + task.data['service'] = self.getClassName() task.setWaiting(100) self._processCaptcha(task) else: @@ -155,7 +155,7 @@ class CaptchaBrotherhood(Hook): def captchaInvalid(self, task): - if task.data['service'] == self.__class__.__name__ and "ticket" in task.data: + if task.data['service'] == self.getClassName() and "ticket" in task.data: res = self.api_response("complainCaptcha", task.data['ticket']) diff --git a/pyload/plugin/hook/DeathByCaptcha.py b/pyload/plugin/hook/DeathByCaptcha.py index b28848422..71d1ddb0a 100644 --- a/pyload/plugin/hook/DeathByCaptcha.py +++ b/pyload/plugin/hook/DeathByCaptcha.py @@ -188,13 +188,13 @@ class DeathByCaptcha(Hook): if balance > rate: task.handler.append(self) - task.data['service'] = self.__class__.__name__ + task.data['service'] = self.getClassName() task.setWaiting(180) self._processCaptcha(task) def captchaInvalid(self, task): - if task.data['service'] == self.__class__.__name__ and "ticket" in task.data: + if task.data['service'] == self.getClassName() and "ticket" in task.data: try: res = self.api_response("captcha/%d/report" % task.data['ticket'], True) diff --git a/pyload/plugin/hook/ImageTyperz.py b/pyload/plugin/hook/ImageTyperz.py index 5dadc09f1..641016546 100644 --- a/pyload/plugin/hook/ImageTyperz.py +++ b/pyload/plugin/hook/ImageTyperz.py @@ -118,16 +118,16 @@ class ImageTyperz(Hook): if self.getCredits() > 0: task.handler.append(self) - task.data['service'] = self.__class__.__name__ + task.data['service'] = self.getClassName() task.setWaiting(100) self._processCaptcha(task) else: - self.logInfo(_("Your %s account has not enough credits") % self.__class__.__name__) + self.logInfo(_("Your %s account has not enough credits") % self.getClassName()) def captchaInvalid(self, task): - if task.data['service'] == self.__class__.__name__ and "ticket" in task.data: + if task.data['service'] == self.getClassName() and "ticket" in task.data: res = getURL(self.RESPOND_URL, post={'action': "SETBADIMAGE", 'username': self.getConfig('username'), diff --git a/pyload/plugin/hoster/FileserveCom.py b/pyload/plugin/hoster/FileserveCom.py index a7bb22440..5f93cbd10 100644 --- a/pyload/plugin/hoster/FileserveCom.py +++ b/pyload/plugin/hoster/FileserveCom.py @@ -144,7 +144,7 @@ class FileserveCom(Hoster): if "fail" in res: self.fail(_("Failed getting wait time")) - if self.__class__.__name__ == "FilejungleCom": + if self.getClassName() == "FilejungleCom": m = re.search(r'"waitTime":(\d+)', res) if m is None: self.fail(_("Cannot get wait time")) @@ -184,7 +184,7 @@ class FileserveCom(Hoster): def handlePremium(self, pyfile): premium_url = None - if self.__class__.__name__ == "FileserveCom": + if self.getClassName() == "FileserveCom": #try api download res = self.load("http://app.fileserve.com/api/download/premium/", post={"username": self.user, diff --git a/pyload/plugin/hoster/NoPremiumPl.py b/pyload/plugin/hoster/NoPremiumPl.py index 8921afe1c..be1e4794e 100644 --- a/pyload/plugin/hoster/NoPremiumPl.py +++ b/pyload/plugin/hoster/NoPremiumPl.py @@ -79,7 +79,7 @@ class NoPremiumPl(MultiHoster): if "errno" in parsed.keys(): if parsed['errno'] in self.ERROR_CODES: # error code in known - self.fail(self.ERROR_CODES[parsed['errno']] % self.__class__.__name__) + self.fail(self.ERROR_CODES[parsed['errno']] % self.getClassName()) else: # error code isn't yet added to plugin self.fail( diff --git a/pyload/plugin/hoster/RapideoPl.py b/pyload/plugin/hoster/RapideoPl.py index e19ccc45b..35d4da0ad 100644 --- a/pyload/plugin/hoster/RapideoPl.py +++ b/pyload/plugin/hoster/RapideoPl.py @@ -79,7 +79,7 @@ class RapideoPl(MultiHoster): if "errno" in parsed.keys(): if parsed['errno'] in self.ERROR_CODES: # error code in known - self.fail(self.ERROR_CODES[parsed['errno']] % self.__class__.__name__) + self.fail(self.ERROR_CODES[parsed['errno']] % self.getClassName()) else: # error code isn't yet added to plugin self.fail( diff --git a/pyload/plugin/hoster/XFileSharingPro.py b/pyload/plugin/hoster/XFileSharingPro.py index 8274a818a..140a69a72 100644 --- a/pyload/plugin/hoster/XFileSharingPro.py +++ b/pyload/plugin/hoster/XFileSharingPro.py @@ -23,13 +23,13 @@ class XFileSharingPro(XFSHoster): def _log(self, type, args): msg = " | ".join(str(a).strip() for a in args if a) logger = getattr(self.log, type) - logger("%s: %s: %s" % (self.__class__.__name__, self.HOSTER_NAME, msg or _("%s MARK" % type.upper()))) + logger("%s: %s: %s" % (self.getClassName(), self.HOSTER_NAME, msg or _("%s MARK" % type.upper()))) def init(self): super(XFileSharingPro, self).init() - self.__pattern = self.core.pluginManager.hosterPlugins[self.__class__.__name__]['pattern'] + self.__pattern = self.core.pluginManager.hosterPlugins[self.getClassName()]['pattern'] self.HOSTER_DOMAIN = re.match(self.__pattern, self.pyfile.url).group("DOMAIN").lower() self.HOSTER_NAME = "".join(part.capitalize() for part in re.split(r'(\.|\d+)', self.HOSTER_DOMAIN) if part != '.') diff --git a/pyload/plugin/hoster/Xdcc.py b/pyload/plugin/hoster/Xdcc.py index 42491404f..30c7b7c22 100644 --- a/pyload/plugin/hoster/Xdcc.py +++ b/pyload/plugin/hoster/Xdcc.py @@ -36,7 +36,7 @@ class Xdcc(Hoster): def process(self, pyfile): # change request type - self.req = pyfile.m.core.requestFactory.getRequest(self.__class__.__name__, type="XDCC") + self.req = pyfile.m.core.requestFactory.getRequest(self.getClassName(), type="XDCC") self.pyfile = pyfile for _i in xrange(0, 3): diff --git a/pyload/plugin/internal/MultiHook.py b/pyload/plugin/internal/MultiHook.py index 8140e2431..dc97ffea9 100644 --- a/pyload/plugin/internal/MultiHook.py +++ b/pyload/plugin/internal/MultiHook.py @@ -69,7 +69,7 @@ class MultiHook(Hook): def initPlugin(self): - self.pluginname = self.__class__.__name__ + self.pluginname = self.getClassName() plugin, self.plugintype = self.core.pluginManager.findPlugin(("hoster", "crypter", "container"), self.pluginname) if plugin: diff --git a/pyload/plugin/internal/MultiHoster.py b/pyload/plugin/internal/MultiHoster.py index a7e74b2ff..8dbcf4f30 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.__class__.__name__]: - hdict = self.core.pluginManager.hosterPlugins[self.__class__.__name__] + and "new_module" in self.core.pluginManager.hosterPlugins[self.getClassName()]: + hdict = self.core.pluginManager.hosterPlugins[self.getClassName()] 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 930f5a313..df98c1e67 100644 --- a/pyload/plugin/internal/SimpleHoster.py +++ b/pyload/plugin/internal/SimpleHoster.py @@ -434,7 +434,7 @@ class SimpleHoster(Hoster): set_cookies(self.req.cj, self.COOKIES) if (self.MULTI_HOSTER - and (self.__pattern != self.core.pluginManager.hosterPlugins[self.__class__.__name__]['pattern'] + and (self.__pattern != self.core.pluginManager.hosterPlugins[self.getClassName()]['pattern'] or re.match(self.__pattern, self.pyfile.url) is None)): self.multihost = True return @@ -746,7 +746,7 @@ class SimpleHoster(Hoster): return self.premium = False self.account = None - self.req = self.core.requestFactory.getRequest(self.__class__.__name__) + self.req = self.core.requestFactory.getRequest(self.getClassName()) self.retries = 0 raise Retry(_("Fallback to free download")) diff --git a/pyload/plugin/internal/XFSCrypter.py b/pyload/plugin/internal/XFSCrypter.py index 6a3f09e55..6c3a97405 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.__class__.__name__ + ".py").replace("Folder.py", "").replace(".py", "") + account_name = (self.getClassName() + ".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 7b8149bc3..ff8077f81 100644 --- a/pyload/plugin/internal/XFSHoster.py +++ b/pyload/plugin/internal/XFSHoster.py @@ -65,7 +65,7 @@ class XFSHoster(SimpleHoster): if self.account: account = self.account else: - account = self.pyfile.m.core.accountManager.getAccountPlugin(self.__class__.__name__) + account = self.pyfile.m.core.accountManager.getAccountPlugin(self.getClassName()) if account and hasattr(account, "HOSTER_DOMAIN") and account.HOSTER_DOMAIN: self.HOSTER_DOMAIN = account.HOSTER_DOMAIN |