summaryrefslogtreecommitdiffstats
path: root/module/plugins/hooks
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hooks')
-rw-r--r--module/plugins/hooks/BypassCaptcha.py24
-rwxr-xr-xmodule/plugins/hooks/Captcha9kw.py2
-rw-r--r--module/plugins/hooks/CaptchaBrotherhood.py34
-rw-r--r--module/plugins/hooks/DeathByCaptcha.py46
-rw-r--r--module/plugins/hooks/ExpertDecoders.py18
-rw-r--r--module/plugins/hooks/ExtractArchive.py16
-rw-r--r--module/plugins/hooks/HotFolder.py2
-rw-r--r--module/plugins/hooks/IRCInterface.py2
-rw-r--r--module/plugins/hooks/ImageTyperz.py45
-rw-r--r--module/plugins/hooks/LinkdecrypterCom.py2
-rw-r--r--module/plugins/hooks/RPNetBiz.py6
-rw-r--r--module/plugins/hooks/XMPPInterface.py2
12 files changed, 103 insertions, 96 deletions
diff --git a/module/plugins/hooks/BypassCaptcha.py b/module/plugins/hooks/BypassCaptcha.py
index b8b55ac63..7e1ea6424 100644
--- a/module/plugins/hooks/BypassCaptcha.py
+++ b/module/plugins/hooks/BypassCaptcha.py
@@ -53,9 +53,9 @@ class BypassCaptcha(Hook):
def getCredits(self):
- response = getURL(self.GETCREDITS_URL, post={"key": self.getConfig("passkey")})
+ res = getURL(self.GETCREDITS_URL, post={"key": self.getConfig("passkey")})
- data = dict([x.split(' ', 1) for x in response.splitlines()])
+ data = dict([x.split(' ', 1) for x in res.splitlines()])
return int(data['Left'])
@@ -66,18 +66,18 @@ class BypassCaptcha(Hook):
req.c.setopt(LOW_SPEED_TIME, 80)
try:
- response = req.load(self.SUBMIT_URL,
- post={"vendor_key": self.PYLOAD_KEY,
- "key": self.getConfig("passkey"),
- "gen_task_id": "1",
- "file": (FORM_FILE, captcha)},
- multipart=True)
+ res = req.load(self.SUBMIT_URL,
+ post={'vendor_key': self.PYLOAD_KEY,
+ 'key': self.getConfig("passkey"),
+ 'gen_task_id': "1",
+ 'file': (FORM_FILE, captcha)},
+ multipart=True)
finally:
req.close()
- data = dict([x.split(' ', 1) for x in response.splitlines()])
+ data = dict([x.split(' ', 1) for x in res.splitlines()])
if not data or "Value" not in data:
- raise BypassCaptchaException(response)
+ raise BypassCaptchaException(res)
result = data['Value']
ticket = data['TaskId']
@@ -88,10 +88,10 @@ class BypassCaptcha(Hook):
def respond(self, ticket, success):
try:
- response = getURL(self.RESPOND_URL, post={"task_id": ticket, "key": self.getConfig("passkey"),
+ res = getURL(self.RESPOND_URL, post={"task_id": ticket, "key": self.getConfig("passkey"),
"cv": 1 if success else 0})
except BadHeader, e:
- self.logError(_("Could not send response"), str(e))
+ self.logError(_("Could not send response"), e)
def newCaptchaTask(self, task):
diff --git a/module/plugins/hooks/Captcha9kw.py b/module/plugins/hooks/Captcha9kw.py
index e831d977c..c8f034847 100755
--- a/module/plugins/hooks/Captcha9kw.py
+++ b/module/plugins/hooks/Captcha9kw.py
@@ -64,7 +64,7 @@ class Captcha9kw(Hook):
with open(task.captchaFile, 'rb') as f:
data = f.read()
except IOError, e:
- self.logError(str(e))
+ self.logError(e)
return
data = b64encode(data)
diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py
index eb0bd9e67..2ebeb1734 100644
--- a/module/plugins/hooks/CaptchaBrotherhood.py
+++ b/module/plugins/hooks/CaptchaBrotherhood.py
@@ -59,12 +59,12 @@ class CaptchaBrotherhood(Hook):
def getCredits(self):
- response = getURL(self.API_URL + "askCredits.aspx",
- get={"username": self.getConfig("username"), "password": self.getConfig("passkey")})
- if not response.startswith("OK"):
- raise CaptchaBrotherhoodException(response)
+ res = getURL(self.API_URL + "askCredits.aspx",
+ get={"username": self.getConfig("username"), "password": self.getConfig("passkey")})
+ if not res.startswith("OK"):
+ raise CaptchaBrotherhoodException(res)
else:
- credits = int(response[3:])
+ credits = int(res[3:])
self.logInfo(_("%d credits left") % credits)
self.info['credits'] = credits
return credits
@@ -101,35 +101,35 @@ class CaptchaBrotherhood(Hook):
try:
req.c.perform()
- response = req.getResponse()
+ res = req.getResponse()
except Exception, e:
raise CaptchaBrotherhoodException("Submit captcha image failed")
req.close()
- if not response.startswith("OK"):
- raise CaptchaBrotherhoodException(response[1])
+ if not res.startswith("OK"):
+ raise CaptchaBrotherhoodException(res[1])
- ticket = response[3:]
+ ticket = res[3:]
for _i in xrange(15):
sleep(5)
- response = self.get_api("askCaptchaResult", ticket)
- if response.startswith("OK-answered"):
- return ticket, response[12:]
+ res = self.get_api("askCaptchaResult", ticket)
+ if res.startswith("OK-answered"):
+ return ticket, res[12:]
raise CaptchaBrotherhoodException("No solution received in time")
def get_api(self, api, ticket):
- response = getURL("%s%s.aspx" % (self.API_URL, api),
+ res = getURL("%s%s.aspx" % (self.API_URL, api),
get={"username": self.getConfig("username"),
"password": self.getConfig("passkey"),
"captchaID": ticket})
- if not response.startswith("OK"):
- raise CaptchaBrotherhoodException("Unknown response: %s" % response)
+ if not res.startswith("OK"):
+ raise CaptchaBrotherhoodException("Unknown response: %s" % res)
- return response
+ return res
def newCaptchaTask(self, task):
@@ -156,7 +156,7 @@ class CaptchaBrotherhood(Hook):
def captchaInvalid(self, task):
if task.data['service'] == self.__name__ and "ticket" in task.data:
- response = self.get_api("complainCaptcha", task.data['ticket'])
+ res = self.get_api("complainCaptcha", task.data['ticket'])
def processCaptcha(self, task):
diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py
index 42495f5fb..df09769ce 100644
--- a/module/plugins/hooks/DeathByCaptcha.py
+++ b/module/plugins/hooks/DeathByCaptcha.py
@@ -81,18 +81,18 @@ class DeathByCaptcha(Hook):
post.update({"username": self.getConfig("username"),
"password": self.getConfig("passkey")})
- response = None
+ res = None
try:
json = req.load("%s%s" % (self.API_URL, api),
post=post,
multipart=multipart)
self.logDebug(json)
- response = json_loads(json)
+ res = json_loads(json)
- if "error" in response:
- raise DeathByCaptchaException(response['error'])
- elif "status" not in response:
- raise DeathByCaptchaException(str(response))
+ if "error" in res:
+ raise DeathByCaptchaException(res['error'])
+ elif "status" not in res:
+ raise DeathByCaptchaException(str(res))
except BadHeader, e:
if 403 == e.code:
@@ -109,24 +109,24 @@ class DeathByCaptcha(Hook):
finally:
req.close()
- return response
+ return res
def getCredits(self):
- response = self.call_api("user", True)
+ res = self.call_api("user", True)
- if 'is_banned' in response and response['is_banned']:
+ if 'is_banned' in res and res['is_banned']:
raise DeathByCaptchaException('banned')
- elif 'balance' in response and 'rate' in response:
- self.info.update(response)
+ elif 'balance' in res and 'rate' in res:
+ self.info.update(res)
else:
- raise DeathByCaptchaException(response)
+ raise DeathByCaptchaException(res)
def getStatus(self):
- response = self.call_api("status", False)
+ res = self.call_api("status", False)
- if 'is_service_overloaded' in response and response['is_service_overloaded']:
+ if 'is_service_overloaded' in res and res['is_service_overloaded']:
raise DeathByCaptchaException('service-overload')
@@ -141,21 +141,21 @@ class DeathByCaptcha(Hook):
data = f.read()
data = "base64:" + b64encode(data)
- response = self.call_api("captcha", {"captchafile": data}, multipart)
+ res = self.call_api("captcha", {"captchafile": data}, multipart)
- if "captcha" not in response:
- raise DeathByCaptchaException(response)
- ticket = response['captcha']
+ if "captcha" not in res:
+ raise DeathByCaptchaException(res)
+ ticket = res['captcha']
for _i in xrange(24):
sleep(5)
- response = self.call_api("captcha/%d" % ticket, False)
- if response['text'] and response['is_correct']:
+ res = self.call_api("captcha/%d" % ticket, False)
+ if res['text'] and res['is_correct']:
break
else:
raise DeathByCaptchaException('timed-out')
- result = response['text']
+ result = res['text']
self.logDebug("Result %s : %s" % (ticket, result))
return ticket, result
@@ -196,9 +196,11 @@ class DeathByCaptcha(Hook):
def captchaInvalid(self, task):
if task.data['service'] == self.__name__ and "ticket" in task.data:
try:
- response = self.call_api("captcha/%d/report" % task.data['ticket'], True)
+ res = self.call_api("captcha/%d/report" % task.data['ticket'], True)
+
except DeathByCaptchaException, e:
self.logError(e.getDesc())
+
except Exception, e:
self.logError(e)
diff --git a/module/plugins/hooks/ExpertDecoders.py b/module/plugins/hooks/ExpertDecoders.py
index faaba6906..1b9459eb6 100644
--- a/module/plugins/hooks/ExpertDecoders.py
+++ b/module/plugins/hooks/ExpertDecoders.py
@@ -34,14 +34,14 @@ class ExpertDecoders(Hook):
def getCredits(self):
- response = getURL(self.API_URL, post={"key": self.getConfig("passkey"), "action": "balance"})
+ res = getURL(self.API_URL, post={"key": self.getConfig("passkey"), "action": "balance"})
- if response.isdigit():
- self.logInfo(_("%s credits left") % response)
- self.info['credits'] = credits = int(response)
+ if res.isdigit():
+ self.logInfo(_("%s credits left") % res)
+ self.info['credits'] = credits = int(res)
return credits
else:
- self.logError(response)
+ self.logError(res)
return 0
@@ -90,9 +90,9 @@ class ExpertDecoders(Hook):
if "ticket" in task.data:
try:
- response = getURL(self.API_URL, post={"action": "refund", "key": self.getConfig("passkey"),
- "gen_task_id": task.data['ticket']})
- self.logInfo(_("Request refund"), response)
+ res = getURL(self.API_URL,
+ post={'action': "refund", 'key': self.getConfig("passkey"), 'gen_task_id': task.data['ticket']})
+ self.logInfo(_("Request refund", res)
except BadHeader, e:
- self.logError(_("Could not send refund request"), str(e))
+ self.logError(_("Could not send refund request"), e)
diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py
index f5f30fc52..11c44a6d1 100644
--- a/module/plugins/hooks/ExtractArchive.py
+++ b/module/plugins/hooks/ExtractArchive.py
@@ -98,12 +98,12 @@ class ExtractArchive(Hook):
if e.errno == 2:
self.logInfo(_("No %s installed") % p)
else:
- self.logWarning(_("Could not activate %s") % p, str(e))
+ self.logWarning(_("Could not activate %s") % p, e)
if self.core.debug:
print_exc()
except Exception, e:
- self.logWarning(_("Could not activate %s") % p, str(e))
+ self.logWarning(_("Could not activate %s") % p, e)
if self.core.debug:
print_exc()
@@ -202,7 +202,7 @@ class ExtractArchive(Hook):
password = p.password.strip().splitlines()
new_files = self._extract(klass, fid, password, thread)
except Exception, e:
- self.logError(basename(target), str(e))
+ self.logError(basename(target), e)
success = False
continue
@@ -289,13 +289,13 @@ class ExtractArchive(Hook):
return extracted_files
except ArchiveError, e:
- self.logError(basename(plugin.file), _("Archive Error"), str(e))
+ self.logError(basename(plugin.file), _("Archive Error"), e)
except CRCError:
self.logError(basename(plugin.file), _("CRC Mismatch"))
except Exception, e:
if self.core.debug:
print_exc()
- self.logError(basename(plugin.file), _("Unknown Error"), str(e))
+ self.logError(basename(plugin.file), _("Unknown Error"), e)
self.manager.dispatchEvent("archive_extract_failed", pyfile)
raise Exception(_("Extract failed"))
@@ -317,7 +317,7 @@ class ExtractArchive(Hook):
passwords.append(pw)
except IOError, e:
- self.logError(str(e))
+ self.logError(e)
else:
self.passwords = passwords
@@ -338,7 +338,7 @@ class ExtractArchive(Hook):
for pw in self.passwords:
f.write(pw + "\n")
except IOError, e:
- self.logError(str(e))
+ self.logError(e)
def setPermissions(self, files):
@@ -357,4 +357,4 @@ class ExtractArchive(Hook):
gid = getgrnam(self.config['permission']['group'])[2]
chown(f, uid, gid)
except Exception, e:
- self.logWarning(_("Setting User and Group failed"), str(e))
+ self.logWarning(_("Setting User and Group failed"), e)
diff --git a/module/plugins/hooks/HotFolder.py b/module/plugins/hooks/HotFolder.py
index 15a8f43d5..518bbac2b 100644
--- a/module/plugins/hooks/HotFolder.py
+++ b/module/plugins/hooks/HotFolder.py
@@ -61,4 +61,4 @@ class HotFolder(Hook):
self.core.api.addPackage(f, [newpath], 1)
except IOError, e:
- self.logError(str(e))
+ self.logError(e)
diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py
index 4d0cd1619..98edc2f7f 100644
--- a/module/plugins/hooks/IRCInterface.py
+++ b/module/plugins/hooks/IRCInterface.py
@@ -187,7 +187,7 @@ class IRCInterface(Thread, Hook):
for line in res:
self.response(line, msg['origin'])
except Exception, e:
- self.logError(str(e))
+ self.logError(e)
def response(self, msg, origin=""):
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):
diff --git a/module/plugins/hooks/LinkdecrypterCom.py b/module/plugins/hooks/LinkdecrypterCom.py
index 6194f67f1..0c5f6e754 100644
--- a/module/plugins/hooks/LinkdecrypterCom.py
+++ b/module/plugins/hooks/LinkdecrypterCom.py
@@ -21,7 +21,7 @@ class LinkdecrypterCom(Hook):
try:
self.loadPatterns()
except Exception, e:
- self.logError(str(e))
+ self.logError(e)
def loadPatterns(self):
diff --git a/module/plugins/hooks/RPNetBiz.py b/module/plugins/hooks/RPNetBiz.py
index 94c7dbff7..01591354d 100644
--- a/module/plugins/hooks/RPNetBiz.py
+++ b/module/plugins/hooks/RPNetBiz.py
@@ -28,9 +28,9 @@ class RPNetBiz(MultiHoster):
# Get account data
(user, data) = self.account.selectAccount()
- response = getURL("https://premium.rpnet.biz/client_api.php",
- get={"username": user, "password": data['password'], "action": "showHosterList"})
- hoster_list = json_loads(response)
+ res = getURL("https://premium.rpnet.biz/client_api.php",
+ get={"username": user, "password": data['password'], "action": "showHosterList"})
+ hoster_list = json_loads(res)
# If account is not valid thera are no hosters available
if 'error' in hoster_list:
diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py
index e23398023..bbeab4341 100644
--- a/module/plugins/hooks/XMPPInterface.py
+++ b/module/plugins/hooks/XMPPInterface.py
@@ -168,7 +168,7 @@ class XMPPInterface(IRCInterface, JabberClient):
messages.append(m)
except Exception, e:
- self.logError(str(e))
+ self.logError(e)
return messages