From 48c0c42fd6faffc56432d5f037cd575979f180cc Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 14 Jul 2014 02:23:37 +0200 Subject: Removed all @author flags + key attributes cleanup for internal & hooks plugins --- module/plugins/hooks/ImageTyperz.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks/ImageTyperz.py') diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index e2e9d93d5..3c23f9567 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, see . - - @author: mkaay, RaNaN, zoidberg """ from __future__ import with_statement from thread import start_new_thread @@ -43,11 +41,14 @@ class ImageTyperzException(Exception): class ImageTyperz(Hook): __name__ = "ImageTyperz" __version__ = "0.04" - __description__ = """Send captchas to ImageTyperz.com""" + __type__ = "hook" + __config__ = [("activated", "bool", "Activated", False), ("username", "str", "Username", ""), ("passkey", "password", "Password", ""), ("force", "bool", "Force IT even if client is connected", False)] + + __description__ = """Send captchas to ImageTyperz.com""" __author_name__ = ("RaNaN", "zoidberg") __author_mail__ = ("RaNaN@pyload.org", "zoidberg@mujmail.cz") @@ -55,6 +56,7 @@ class ImageTyperz(Hook): RESPOND_URL = "http://captchatypers.com/Forms/SetBadImage.ashx" GETCREDITS_URL = "http://captchatypers.com/Forms/RequestBalance.ashx" + def setup(self): self.info = {} -- cgit v1.2.3 From 5060e4c6374a5116d0d8b02528f910f8c5f8bcf9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 15 Jul 2014 16:25:41 +0200 Subject: Fix code indentation, some bad whitespaces and missing authors + use 'not' instead 'is None' + replace __pattern__'s r" with r' + other minor cosmetics --- module/plugins/hooks/ImageTyperz.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/plugins/hooks/ImageTyperz.py') diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index 3c23f9567..794db3913 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -25,6 +25,7 @@ from module.plugins.Hook import Hook class ImageTyperzException(Exception): + def __init__(self, err): self.err = err -- cgit v1.2.3 From 7b8c458cca7d21a029620f98e453f746fce69cd1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 14 Jul 2014 16:10:01 +0200 Subject: Prefer single quote for dict key name --- module/plugins/hooks/ImageTyperz.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks/ImageTyperz.py') diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index 794db3913..4d7be96e3 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -136,7 +136,7 @@ class ImageTyperz(Hook): if task.data['service'] == self.__name__ and "ticket" in task.data: response = getURL(self.RESPOND_URL, post={"action": "SETBADIMAGE", "username": self.getConfig("username"), "password": self.getConfig("passkey"), - "imageid": task.data["ticket"]}) + "imageid": task.data['ticket']}) if response == "SUCCESS": self.logInfo("Bad captcha solution received, requested refund") @@ -151,5 +151,5 @@ class ImageTyperz(Hook): task.error = e.getCode() return - task.data["ticket"] = ticket + task.data['ticket'] = ticket task.setResult(result) -- cgit v1.2.3 From ba916633f2bedb04c7358000b91aed69f52e8e43 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 1 Aug 2014 19:35:59 +0200 Subject: Remove trailing whitespaces + remove license headers + import urllib methods directly + sort and fix key attributes + use save_join instead join + sort some import declarations + other minor code cosmetics --- module/plugins/hooks/ImageTyperz.py | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'module/plugins/hooks/ImageTyperz.py') diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index 4d7be96e3..d9d4e547e 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -1,24 +1,12 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -""" from __future__ import with_statement -from thread import start_new_thread -from pycurl import FORM_FILE, LOW_SPEED_TIME + import re + from base64 import b64encode +from pycurl import FORM_FILE, LOW_SPEED_TIME +from thread import start_new_thread from module.network.RequestFactory import getURL, getRequest from module.plugins.Hook import Hook @@ -41,8 +29,8 @@ class ImageTyperzException(Exception): class ImageTyperz(Hook): __name__ = "ImageTyperz" - __version__ = "0.04" __type__ = "hook" + __version__ = "0.04" __config__ = [("activated", "bool", "Activated", False), ("username", "str", "Username", ""), @@ -82,7 +70,7 @@ class ImageTyperz(Hook): req.c.setopt(LOW_SPEED_TIME, 80) try: - #workaround multipart-post bug in HTTPRequest.py + #workaround multipart-post bug in HTTPRequest.py if re.match("^[A-Za-z0-9]*$", self.getConfig("passkey")): multipart = True data = (FORM_FILE, captcha) -- cgit v1.2.3 From 0d220d634e512d89bda540f91c643b361c82ea8a Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 27 Sep 2014 01:38:32 +0200 Subject: Logging string cosmetics --- module/plugins/hooks/ImageTyperz.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks/ImageTyperz.py') diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index d9d4e547e..a3e16b522 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -61,7 +61,7 @@ class ImageTyperz(Hook): except: raise ImageTyperzException("invalid response") - self.logInfo("Account balance: $%s left" % response) + self.logInfo(_("Account balance: $%s left") % response) return balance def submit(self, captcha, captchaType="file", match=None): @@ -118,7 +118,7 @@ class ImageTyperz(Hook): start_new_thread(self.processCaptcha, (task,)) else: - self.logInfo("Your %s account has not enough credits" % self.__name__) + self.logInfo(_("Your %s account has not enough credits") % self.__name__) def captchaInvalid(self, task): if task.data['service'] == self.__name__ and "ticket" in task.data: @@ -127,9 +127,9 @@ class ImageTyperz(Hook): "imageid": task.data['ticket']}) if response == "SUCCESS": - self.logInfo("Bad captcha solution received, requested refund") + self.logInfo(_("Bad captcha solution received, requested refund")) else: - self.logError("Bad captcha solution received, refund request failed", response) + self.logError(_("Bad captcha solution received, refund request failed"), response) def processCaptcha(self, task): c = task.captchaFile -- cgit v1.2.3 From b0868ae6446078bacf1635dde5e4ab316b4a94cb Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 7 Oct 2014 18:57:59 +0200 Subject: New __authors__ key replaces __author_name__ and __author_mail__ + Whitespaces and EOF fixup --- module/plugins/hooks/ImageTyperz.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks/ImageTyperz.py') diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index a3e16b522..6e63b8a0d 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -38,8 +38,9 @@ class ImageTyperz(Hook): ("force", "bool", "Force IT even if client is connected", False)] __description__ = """Send captchas to ImageTyperz.com""" - __author_name__ = ("RaNaN", "zoidberg") - __author_mail__ = ("RaNaN@pyload.org", "zoidberg@mujmail.cz") + __authors__ = [("RaNaN", "RaNaN@pyload.org"), + ("zoidberg", "zoidberg@mujmail.cz")] + SUBMIT_URL = "http://captchatypers.com/Forms/UploadFileAndGetTextNEW.ashx" RESPOND_URL = "http://captchatypers.com/Forms/SetBadImage.ashx" -- cgit v1.2.3 From ae7a7e66981456e5bbe2b54006d79b6f907be7a4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 8 Oct 2014 20:18:13 +0200 Subject: Add __license__ key attribute to plugins --- module/plugins/hooks/ImageTyperz.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/plugins/hooks/ImageTyperz.py') diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index 6e63b8a0d..aaa3c7bbd 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -38,6 +38,7 @@ class ImageTyperz(Hook): ("force", "bool", "Force IT even if client is connected", False)] __description__ = """Send captchas to ImageTyperz.com""" + __license__ = "GPLv3" __authors__ = [("RaNaN", "RaNaN@pyload.org"), ("zoidberg", "zoidberg@mujmail.cz")] -- cgit v1.2.3 From f76e5c2336718dca9da8033ba22cd83c72c7b3b3 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 11 Oct 2014 15:14:28 +0200 Subject: Pattern update 1 --- module/plugins/hooks/ImageTyperz.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/ImageTyperz.py') diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index aaa3c7bbd..b7ee6b105 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -73,7 +73,7 @@ class ImageTyperz(Hook): try: #workaround multipart-post bug in HTTPRequest.py - if re.match("^[A-Za-z0-9]*$", self.getConfig("passkey")): + if re.match("^\w*$", self.getConfig("passkey")): multipart = True data = (FORM_FILE, captcha) else: -- cgit v1.2.3 From 0eb6e7ec4a1144dcca824d8add049787d3da1762 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 22 Oct 2014 19:44:59 +0200 Subject: Two space before function declaration --- module/plugins/hooks/ImageTyperz.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'module/plugins/hooks/ImageTyperz.py') diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index b7ee6b105..3eb0acd64 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -17,12 +17,15 @@ class ImageTyperzException(Exception): def __init__(self, err): self.err = err + def getCode(self): return self.err + def __str__(self): return "" % self.err + def __repr__(self): return "" % self.err @@ -51,6 +54,7 @@ class ImageTyperz(Hook): def setup(self): self.info = {} + def getCredits(self): response = getURL(self.GETCREDITS_URL, post={"action": "REQUESTBALANCE", "username": self.getConfig("username"), "password": self.getConfig("passkey")}) @@ -66,6 +70,7 @@ class ImageTyperz(Hook): self.logInfo(_("Account balance: $%s left") % response) return balance + def submit(self, captcha, captchaType="file", match=None): req = getRequest() #raise timeout threshold @@ -100,6 +105,7 @@ class ImageTyperz(Hook): return ticket, result + def newCaptchaTask(self, task): if "service" in task.data: return False @@ -122,6 +128,7 @@ class ImageTyperz(Hook): else: self.logInfo(_("Your %s account has not enough credits") % self.__name__) + def captchaInvalid(self, task): if task.data['service'] == self.__name__ and "ticket" in task.data: response = getURL(self.RESPOND_URL, post={"action": "SETBADIMAGE", "username": self.getConfig("username"), @@ -133,6 +140,7 @@ class ImageTyperz(Hook): else: self.logError(_("Bad captcha solution received, refund request failed"), response) + def processCaptcha(self, task): c = task.captchaFile try: -- cgit v1.2.3 From 885f8ed782e64d9e73367905e642a84d0a8999f1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 28 Oct 2014 04:01:38 +0100 Subject: Update __config__ --- module/plugins/hooks/ImageTyperz.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'module/plugins/hooks/ImageTyperz.py') diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index 3eb0acd64..baa62ce31 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -35,8 +35,7 @@ class ImageTyperz(Hook): __type__ = "hook" __version__ = "0.04" - __config__ = [("activated", "bool", "Activated", False), - ("username", "str", "Username", ""), + __config__ = [("username", "str", "Username", ""), ("passkey", "password", "Password", ""), ("force", "bool", "Force IT even if client is connected", False)] -- cgit v1.2.3 From 34984dae733c3f3d47b41a0acfba3724d53c65a1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 28 Oct 2014 16:52:10 +0100 Subject: Code cosmetics: plugin class attributes --- module/plugins/hooks/ImageTyperz.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'module/plugins/hooks/ImageTyperz.py') diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index baa62ce31..c0a573c5c 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -31,8 +31,8 @@ class ImageTyperzException(Exception): class ImageTyperz(Hook): - __name__ = "ImageTyperz" - __type__ = "hook" + __name__ = "ImageTyperz" + __type__ = "hook" __version__ = "0.04" __config__ = [("username", "str", "Username", ""), @@ -40,9 +40,9 @@ class ImageTyperz(Hook): ("force", "bool", "Force IT even if client is connected", False)] __description__ = """Send captchas to ImageTyperz.com""" - __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org"), - ("zoidberg", "zoidberg@mujmail.cz")] + __license__ = "GPLv3" + __authors__ = [("RaNaN", "RaNaN@pyload.org"), + ("zoidberg", "zoidberg@mujmail.cz")] SUBMIT_URL = "http://captchatypers.com/Forms/UploadFileAndGetTextNEW.ashx" -- cgit v1.2.3 From 59f72bfc5ed721c80c821bd0ca1bc8daf0d49880 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 9 Nov 2014 03:12:41 +0100 Subject: Code cosmetics --- module/plugins/hooks/ImageTyperz.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/ImageTyperz.py') diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index c0a573c5c..8d253c249 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -51,7 +51,7 @@ class ImageTyperz(Hook): def setup(self): - self.info = {} + self.info = {} #@TODO: Remove in 0.4.10 def getCredits(self): -- cgit v1.2.3 From c9e31d875d32de31e54959b82bc35eff2b3e0f3f Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 10 Nov 2014 00:19:51 +0100 Subject: Code cosmetics --- module/plugins/hooks/ImageTyperz.py | 45 ++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 20 deletions(-) (limited to 'module/plugins/hooks/ImageTyperz.py') diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index 8d253c249..b00c5118f 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -55,18 +55,20 @@ class ImageTyperz(Hook): def getCredits(self): - response = getURL(self.GETCREDITS_URL, post={"action": "REQUESTBALANCE", "username": self.getConfig("username"), - "password": self.getConfig("passkey")}) + res = getURL(self.GETCREDITS_URL, + post={'action': "REQUESTBALANCE", + 'username': self.getConfig("username"), + 'password': self.getConfig("passkey")}) - if response.startswith('ERROR'): - raise ImageTyperzException(response) + if res.startswith('ERROR'): + raise ImageTyperzException(res) try: - balance = float(response) + balance = float(res) except: - raise ImageTyperzException("invalid response") + raise ImageTyperzException("Invalid response") - self.logInfo(_("Account balance: $%s left") % response) + self.logInfo(_("Account balance: $%s left") % res) return balance @@ -86,21 +88,22 @@ class ImageTyperz(Hook): data = f.read() data = b64encode(data) - response = req.load(self.SUBMIT_URL, post={"action": "UPLOADCAPTCHA", - "username": self.getConfig("username"), - "password": self.getConfig("passkey"), "file": data}, - multipart=multipart) + res = req.load(self.SUBMIT_URL, + post={'action': "UPLOADCAPTCHA", + 'username': self.getConfig("username"), + 'password': self.getConfig("passkey"), "file": data}, + multipart=multipart) finally: req.close() - if response.startswith("ERROR"): - raise ImageTyperzException(response) + if res.startswith("ERROR"): + raise ImageTyperzException(res) else: - data = response.split('|') + data = res.split('|') if len(data) == 2: ticket, result = data else: - raise ImageTyperzException("Unknown response %s" % response) + raise ImageTyperzException("Unknown response: %s" % res) return ticket, result @@ -130,14 +133,16 @@ class ImageTyperz(Hook): def captchaInvalid(self, task): if task.data['service'] == self.__name__ and "ticket" in task.data: - response = getURL(self.RESPOND_URL, post={"action": "SETBADIMAGE", "username": self.getConfig("username"), - "password": self.getConfig("passkey"), - "imageid": task.data['ticket']}) + res = getURL(self.RESPOND_URL, + post={'action': "SETBADIMAGE", + 'username': self.getConfig("username"), + 'password': self.getConfig("passkey"), + 'imageid': task.data['ticket']}) - if response == "SUCCESS": + if res == "SUCCESS": self.logInfo(_("Bad captcha solution received, requested refund")) else: - self.logError(_("Bad captcha solution received, refund request failed"), response) + self.logError(_("Bad captcha solution received, refund request failed"), res) def processCaptcha(self, task): -- cgit v1.2.3 From e4c9e4ffc9e3f6bd6b16ce83796dc3d275d544f7 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 9 Dec 2014 01:13:05 +0100 Subject: Don't start unused periodical in some addons --- module/plugins/hooks/ImageTyperz.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'module/plugins/hooks/ImageTyperz.py') diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index b00c5118f..f89d64c37 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -33,7 +33,7 @@ class ImageTyperzException(Exception): class ImageTyperz(Hook): __name__ = "ImageTyperz" __type__ = "hook" - __version__ = "0.04" + __version__ = "0.05" __config__ = [("username", "str", "Username", ""), ("passkey", "password", "Password", ""), @@ -50,6 +50,11 @@ class ImageTyperz(Hook): GETCREDITS_URL = "http://captchatypers.com/Forms/RequestBalance.ashx" + #@TODO: Remove in 0.4.10 + def initPeriodical(self): + pass + + def setup(self): self.info = {} #@TODO: Remove in 0.4.10 -- cgit v1.2.3