From 0e1ef9bc01579328e17e79416fa3c1c7b77adcc8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 8 Jun 2015 06:08:01 +0200 Subject: Update everything --- module/plugins/hooks/DeathByCaptcha.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks/DeathByCaptcha.py') diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index f9618f011..63c2cd41d 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -11,7 +11,7 @@ from base64 import b64encode from module.common.json_layer import json_loads from module.network.HTTPRequest import BadHeader from module.network.RequestFactory import getRequest -from module.plugins.Hook import Hook, threaded +from module.plugins.internal.Hook import Hook, threaded class DeathByCaptchaException(Exception): @@ -51,7 +51,7 @@ class DeathByCaptchaException(Exception): class DeathByCaptcha(Hook): __name__ = "DeathByCaptcha" __type__ = "hook" - __version__ = "0.06" + __version__ = "0.07" __config__ = [("username", "str", "Username", ""), ("passkey", "password", "Password", ""), -- cgit v1.2.3 From f4b893e5ee24769584a2da1866c665489f7019ec Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 15 Jun 2015 06:56:13 +0200 Subject: Hook plugin code cosmetics --- module/plugins/hooks/DeathByCaptcha.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/DeathByCaptcha.py') diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index 63c2cd41d..073f01d57 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -162,7 +162,7 @@ class DeathByCaptcha(Hook): return ticket, result - def newCaptchaTask(self, task): + def captcha_task(self, task): if "service" in task.data: return False -- cgit v1.2.3 From 5a139055ae658d3a05cbb658cbd66aeae0d01db5 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 15 Jun 2015 21:06:10 +0200 Subject: Spare code cosmetics --- module/plugins/hooks/DeathByCaptcha.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/DeathByCaptcha.py') diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index 073f01d57..1ece35bdb 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -194,7 +194,7 @@ class DeathByCaptcha(Hook): self._processCaptcha(task) - def captchaInvalid(self, task): + def captcha_invalid(self, task): if task.data['service'] == self.__name__ and "ticket" in task.data: try: res = self.api_response("captcha/%d/report" % task.data['ticket'], True) -- cgit v1.2.3 From c1764e2fea0bb05164c83a876e8cd58b97f58f25 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 16 Jun 2015 17:31:38 +0200 Subject: Update all --- module/plugins/hooks/DeathByCaptcha.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks/DeathByCaptcha.py') diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index 1ece35bdb..50331d512 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -84,9 +84,11 @@ class DeathByCaptcha(Hook): res = None try: - json = req.load("%s%s" % (self.API_URL, api), - post=post, - multipart=multipart) + json = self.load("%s%s" % (self.API_URL, api), + post=post, + multipart=multipart, + req=req) + self.logDebug(json) res = json_loads(json) -- cgit v1.2.3 From e4fb45b22d36595839e8f638a3f0a4669dba3e8d Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 21 Jun 2015 08:50:26 +0200 Subject: Spare code cosmetics (4) --- module/plugins/hooks/DeathByCaptcha.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'module/plugins/hooks/DeathByCaptcha.py') diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index 50331d512..e0b319e12 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -53,9 +53,9 @@ class DeathByCaptcha(Hook): __type__ = "hook" __version__ = "0.07" - __config__ = [("username", "str", "Username", ""), - ("passkey", "password", "Password", ""), - ("force", "bool", "Force DBC even if client is connected", False)] + __config__ = [("username" , "str" , "Username" , "" ), + ("password" , "password", "Password" , "" ), + ("check_client", "bool" , "Don't use if client is connected", True)] __description__ = """Send captchas to DeathByCaptcha.com""" __license__ = "GPLv3" @@ -80,7 +80,7 @@ class DeathByCaptcha(Hook): if not isinstance(post, dict): post = {} post.update({"username": self.getConfig('username'), - "password": self.getConfig('passkey')}) + "password": self.getConfig('password')}) res = None try: @@ -135,7 +135,7 @@ class DeathByCaptcha(Hook): def submit(self, captcha, captchaType="file", match=None): #@NOTE: Workaround multipart-post bug in HTTPRequest.py - if re.match("^\w*$", self.getConfig('passkey')): + if re.match("^\w*$", self.getConfig('password')): multipart = True data = (pycurl.FORM_FILE, captcha) else: @@ -171,10 +171,10 @@ class DeathByCaptcha(Hook): if not task.isTextual(): return False - if not self.getConfig('username') or not self.getConfig('passkey'): + if not self.getConfig('username') or not self.getConfig('password'): return False - if self.core.isClientConnected() and not self.getConfig('force'): + if self.core.isClientConnected() and self.getConfig('check_client'): return False try: -- cgit v1.2.3 From b1759bc440cd6013837697eb8de540914f693ffd Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 7 Jul 2015 01:23:55 +0200 Subject: No camelCase style anymore --- module/plugins/hooks/DeathByCaptcha.py | 42 +++++++++++++++++----------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'module/plugins/hooks/DeathByCaptcha.py') diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index e0b319e12..ec2554a8f 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -29,11 +29,11 @@ class DeathByCaptchaException(Exception): self.err = err - def getCode(self): + def get_code(self): return self.err - def getDesc(self): + def get_desc(self): if self.err in self.DBC_ERRORS.keys(): return self.DBC_ERRORS[self.err] else: @@ -51,7 +51,7 @@ class DeathByCaptchaException(Exception): class DeathByCaptcha(Hook): __name__ = "DeathByCaptcha" __type__ = "hook" - __version__ = "0.07" + __version__ = "0.08" __config__ = [("username" , "str" , "Username" , "" ), ("password" , "password", "Password" , "" ), @@ -79,8 +79,8 @@ class DeathByCaptcha(Hook): if post: if not isinstance(post, dict): post = {} - post.update({"username": self.getConfig('username'), - "password": self.getConfig('password')}) + post.update({"username": self.get_config('username'), + "password": self.get_config('password')}) res = None try: @@ -89,7 +89,7 @@ class DeathByCaptcha(Hook): multipart=multipart, req=req) - self.logDebug(json) + self.log_debug(json) res = json_loads(json) if "error" in res: @@ -115,7 +115,7 @@ class DeathByCaptcha(Hook): return res - def getCredits(self): + def get_credits(self): res = self.api_response("user", True) if 'is_banned' in res and res['is_banned']: @@ -126,7 +126,7 @@ class DeathByCaptcha(Hook): raise DeathByCaptchaException(res) - def getStatus(self): + def get_status(self): res = self.api_response("status", False) if 'is_service_overloaded' in res and res['is_service_overloaded']: @@ -135,7 +135,7 @@ class DeathByCaptcha(Hook): def submit(self, captcha, captchaType="file", match=None): #@NOTE: Workaround multipart-post bug in HTTPRequest.py - if re.match("^\w*$", self.getConfig('password')): + if re.match("^\w*$", self.get_config('password')): multipart = True data = (pycurl.FORM_FILE, captcha) else: @@ -159,7 +159,7 @@ class DeathByCaptcha(Hook): raise DeathByCaptchaException('timed-out') result = res['text'] - self.logDebug("Result %s : %s" % (ticket, result)) + self.log_debug("Result %s : %s" % (ticket, result)) return ticket, result @@ -171,21 +171,21 @@ class DeathByCaptcha(Hook): if not task.isTextual(): return False - if not self.getConfig('username') or not self.getConfig('password'): + if not self.get_config('username') or not self.get_config('password'): return False - if self.core.isClientConnected() and self.getConfig('check_client'): + if self.core.isClientConnected() and self.get_config('check_client'): return False try: - self.getStatus() - self.getCredits() + self.get_status() + self.get_credits() except DeathByCaptchaException, e: - self.logError(e.getDesc()) + self.log_error(e.getDesc()) return False balance, rate = self.info['balance'], self.info['rate'] - self.logInfo(_("Account balance"), + self.log_info(_("Account balance"), _("US$%.3f (%d captchas left at %.2f cents each)") % (balance / 100, balance // rate, rate)) @@ -193,7 +193,7 @@ class DeathByCaptcha(Hook): task.handler.append(self) task.data['service'] = self.__name__ task.setWaiting(180) - self._processCaptcha(task) + self._process_captcha(task) def captcha_invalid(self, task): @@ -202,20 +202,20 @@ class DeathByCaptcha(Hook): res = self.api_response("captcha/%d/report" % task.data['ticket'], True) except DeathByCaptchaException, e: - self.logError(e.getDesc()) + self.log_error(e.getDesc()) except Exception, e: - self.logError(e) + self.log_error(e) @threaded - def _processCaptcha(self, task): + def _process_captcha(self, task): c = task.captchaFile try: ticket, result = self.submit(c) except DeathByCaptchaException, e: task.error = e.getCode() - self.logError(e.getDesc()) + self.log_error(e.getDesc()) return task.data['ticket'] = ticket -- cgit v1.2.3 From 9e5d813d7721e351ac02ba72bdc473a7d77ba6b7 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 18 Jul 2015 20:04:36 +0200 Subject: Code cosmetics --- module/plugins/hooks/DeathByCaptcha.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks/DeathByCaptcha.py') diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index ec2554a8f..43bad2d0b 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -10,7 +10,7 @@ from base64 import b64encode from module.common.json_layer import json_loads from module.network.HTTPRequest import BadHeader -from module.network.RequestFactory import getRequest +from module.network.RequestFactory import getRequest as get_request from module.plugins.internal.Hook import Hook, threaded @@ -73,7 +73,7 @@ class DeathByCaptcha(Hook): def api_response(self, api="captcha", post=False, multipart=False): - req = getRequest() + req = get_request() req.c.setopt(pycurl.HTTPHEADER, ["Accept: application/json", "User-Agent: pyLoad %s" % self.core.version]) if post: -- cgit v1.2.3 From 502517f37c7540b0bddb092e69386d9d6f08800c Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Jul 2015 09:42:34 +0200 Subject: Fix addons --- module/plugins/hooks/DeathByCaptcha.py | 6 ------ 1 file changed, 6 deletions(-) (limited to 'module/plugins/hooks/DeathByCaptcha.py') diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index 43bad2d0b..6727107ca 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -63,15 +63,9 @@ class DeathByCaptcha(Hook): ("zoidberg", "zoidberg@mujmail.cz")] - interval = 0 #@TODO: Remove in 0.4.10 - API_URL = "http://api.dbcapi.me/api/" - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - - def api_response(self, api="captcha", post=False, multipart=False): req = get_request() req.c.setopt(pycurl.HTTPHEADER, ["Accept: application/json", "User-Agent: pyLoad %s" % self.core.version]) -- cgit v1.2.3 From ff9383bfe06d14d23bc0ed6af79aa8967965d078 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Jul 2015 10:59:52 +0200 Subject: Code cosmetics (3) --- module/plugins/hooks/DeathByCaptcha.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks/DeathByCaptcha.py') diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index 6727107ca..699243ddc 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -73,8 +73,8 @@ class DeathByCaptcha(Hook): if post: if not isinstance(post, dict): post = {} - post.update({"username": self.get_config('username'), - "password": self.get_config('password')}) + post.update({'username': self.get_config('username'), + 'password': self.get_config('password')}) res = None try: @@ -138,7 +138,7 @@ class DeathByCaptcha(Hook): data = f.read() data = "base64:" + b64encode(data) - res = self.api_response("captcha", {"captchafile": data}, multipart) + res = self.api_response("captcha", {'captchafile': data}, multipart) if "captcha" not in res: raise DeathByCaptchaException(res) -- cgit v1.2.3 From 56389e28ba5d2f5658278bc7f486d73be747f135 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Jul 2015 11:44:49 +0200 Subject: Rename self.core to self.pyload (plugins only) --- module/plugins/hooks/DeathByCaptcha.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks/DeathByCaptcha.py') diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index 699243ddc..e11e7305c 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -68,7 +68,7 @@ class DeathByCaptcha(Hook): def api_response(self, api="captcha", post=False, multipart=False): req = get_request() - req.c.setopt(pycurl.HTTPHEADER, ["Accept: application/json", "User-Agent: pyLoad %s" % self.core.version]) + req.c.setopt(pycurl.HTTPHEADER, ["Accept: application/json", "User-Agent: pyLoad %s" % self.pyload.version]) if post: if not isinstance(post, dict): @@ -168,7 +168,7 @@ class DeathByCaptcha(Hook): if not self.get_config('username') or not self.get_config('password'): return False - if self.core.isClientConnected() and self.get_config('check_client'): + if self.pyload.isClientConnected() and self.get_config('check_client'): return False try: -- cgit v1.2.3 From d38e830b7c0b3c6561a0072c74bbccb5fcdf4a61 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Jul 2015 14:43:42 +0200 Subject: New __status__ magic key --- module/plugins/hooks/DeathByCaptcha.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/plugins/hooks/DeathByCaptcha.py') diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index e11e7305c..a139f28a6 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -52,6 +52,7 @@ class DeathByCaptcha(Hook): __name__ = "DeathByCaptcha" __type__ = "hook" __version__ = "0.08" + __status__ = "stable" __config__ = [("username" , "str" , "Username" , "" ), ("password" , "password", "Password" , "" ), -- cgit v1.2.3 From 94d017cd2a5c1f194960827a8c7e46afc3682008 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 24 Jul 2015 06:55:49 +0200 Subject: Hotfixes (2) --- module/plugins/hooks/DeathByCaptcha.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/DeathByCaptcha.py') diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index a139f28a6..baf73d6b8 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -52,7 +52,7 @@ class DeathByCaptcha(Hook): __name__ = "DeathByCaptcha" __type__ = "hook" __version__ = "0.08" - __status__ = "stable" + __status__ = "testing" __config__ = [("username" , "str" , "Username" , "" ), ("password" , "password", "Password" , "" ), -- cgit v1.2.3 From 761ca5c66e07559925ebbdbc6531f9ca658b12ce Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 24 Jul 2015 16:11:58 +0200 Subject: Code cosmetics --- module/plugins/hooks/DeathByCaptcha.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks/DeathByCaptcha.py') diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index baf73d6b8..c27db422b 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -93,11 +93,11 @@ class DeathByCaptcha(Hook): raise DeathByCaptchaException(str(res)) except BadHeader, e: - if 403 == e.code: + if 403 is e.code: raise DeathByCaptchaException('not-logged-in') - elif 413 == e.code: + elif 413 is e.code: raise DeathByCaptchaException('invalid-captcha') - elif 503 == e.code: + elif 503 is e.code: raise DeathByCaptchaException('service-overload') elif e.code in (400, 405): raise DeathByCaptchaException('invalid-request') @@ -192,7 +192,7 @@ class DeathByCaptcha(Hook): def captcha_invalid(self, task): - if task.data['service'] == self.__name__ and "ticket" in task.data: + if task.data['service'] is self.__name__ and "ticket" in task.data: try: res = self.api_response("captcha/%d/report" % task.data['ticket'], True) -- cgit v1.2.3 From 88f98ab3bd6e091c1b6ca6ac9fddc37b2e29694c Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 30 Jul 2015 14:37:44 +0200 Subject: Fix get_code call in captcha hooks --- module/plugins/hooks/DeathByCaptcha.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/DeathByCaptcha.py') diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index c27db422b..98572191e 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -209,7 +209,7 @@ class DeathByCaptcha(Hook): try: ticket, result = self.submit(c) except DeathByCaptchaException, e: - task.error = e.getCode() + task.error = e.get_code() self.log_error(e.getDesc()) return -- cgit v1.2.3