summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-06-27 20:27:38 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-06-27 20:27:38 +0200
commit06d6f4ffda1b1542d9345f246f1c9645d96aeec0 (patch)
tree34a414c9170254ae6e886668a440a1a37d228de8
parentShareonline, zshare fix, testing __slots__ attribute (diff)
downloadpyload-06d6f4ffda1b1542d9345f246f1c9645d96aeec0.tar.xz
closed #345
-rw-r--r--module/network/RequestFactory.py7
-rw-r--r--module/plugins/hooks/CaptchaTrader.py19
-rw-r--r--module/plugins/hooks/XMPPInterface.py2
3 files changed, 20 insertions, 8 deletions
diff --git a/module/network/RequestFactory.py b/module/network/RequestFactory.py
index 44f66efab..6bb7ced62 100644
--- a/module/network/RequestFactory.py
+++ b/module/network/RequestFactory.py
@@ -61,8 +61,11 @@ class RequestFactory():
def getURL(self, *args, **kwargs):
""" see HTTPRequest for argument list """
h = HTTPRequest(None, self.getOptions())
- rep = h.load(*args, **kwargs)
- h.close()
+ try:
+ rep = h.load(*args, **kwargs)
+ finally:
+ h.close()
+
return rep
def getCookieJar(self, pluginName, account=None):
diff --git a/module/plugins/hooks/CaptchaTrader.py b/module/plugins/hooks/CaptchaTrader.py
index af6626897..2bae9401a 100644
--- a/module/plugins/hooks/CaptchaTrader.py
+++ b/module/plugins/hooks/CaptchaTrader.py
@@ -22,9 +22,9 @@ except ImportError:
from simplejson import loads
from thread import start_new_thread
-from pycurl import FORM_FILE
+from pycurl import FORM_FILE, LOW_SPEED_TIME
-from module.network.RequestFactory import getURL
+from module.network.RequestFactory import getURL, getRequest
from module.plugins.Hook import Hook
@@ -45,7 +45,7 @@ class CaptchaTraderException(Exception):
class CaptchaTrader(Hook):
__name__ = "CaptchaTrader"
- __version__ = "0.11"
+ __version__ = "0.12"
__description__ = """send captchas to captchatrader.com"""
__config__ = [("activated", "bool", "Activated", True),
("username", "str", "Username", ""),
@@ -76,12 +76,21 @@ class CaptchaTrader(Hook):
#if type(captcha) == str and captchaType == "file":
# raise CaptchaTraderException("Invalid Type")
assert captchaType in ("file", "url-jpg", "url-jpeg", "url-png", "url-bmp")
- #todo more timeout
- json = getURL(CaptchaTrader.SUBMIT_URL, post={"api_key": PYLOAD_KEY,
+
+ req = getRequest()
+
+ #raise timeout threshold
+ req.c.setopt(LOW_SPEED_TIME, 80)
+
+ try:
+ json = req.load(CaptchaTrader.SUBMIT_URL, post={"api_key": PYLOAD_KEY,
"username": self.getConfig("username"),
"password": self.getConfig("passkey"),
"value": (FORM_FILE, captcha),
"type": captchaType}, multipart=True)
+ finally:
+ req.close()
+
response = loads(json)
if response[0] < 0:
raise CaptchaTraderException(response[1])
diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py
index 8b186ec98..ce937c5d6 100644
--- a/module/plugins/hooks/XMPPInterface.py
+++ b/module/plugins/hooks/XMPPInterface.py
@@ -95,7 +95,7 @@ class XMPPInterface(IRCInterface, JabberClient):
# connect to IRC etc.
self.connect()
try:
- self.loop(1)
+ self.loop()
except Exception, ex:
self.core.log.error("pyLoad XMPP: %s" % str(ex))