diff options
| author | 2011-06-27 20:27:38 +0200 | |
|---|---|---|
| committer | 2011-06-27 20:27:38 +0200 | |
| commit | 06d6f4ffda1b1542d9345f246f1c9645d96aeec0 (patch) | |
| tree | 34a414c9170254ae6e886668a440a1a37d228de8 | |
| parent | Shareonline, zshare fix, testing __slots__ attribute (diff) | |
| download | pyload-06d6f4ffda1b1542d9345f246f1c9645d96aeec0.tar.xz | |
closed #345
| -rw-r--r-- | module/network/RequestFactory.py | 7 | ||||
| -rw-r--r-- | module/plugins/hooks/CaptchaTrader.py | 19 | ||||
| -rw-r--r-- | module/plugins/hooks/XMPPInterface.py | 2 | 
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)) | 
