diff options
| -rw-r--r-- | Plugins/NetloadIn.py | 2 | ||||
| -rw-r--r-- | captcha/captcha.py | 42 | 
2 files changed, 37 insertions, 7 deletions
| diff --git a/Plugins/NetloadIn.py b/Plugins/NetloadIn.py index f3ef99586..a7d6ee4cf 100644 --- a/Plugins/NetloadIn.py +++ b/Plugins/NetloadIn.py @@ -16,7 +16,7 @@ class NetloadIn(Plugin):          props = {}          props['name'] = "NetloadIn"          props['type'] = "hoster" -        props['pattern'] = r"http://.+netload.in/" +        props['pattern'] = r"http://.*netload\.in/"          props['version'] = "0.1"          props['description'] = """Netload.in Download Plugin"""          props['author_name'] = ("spoob", "RaNaN") diff --git a/captcha/captcha.py b/captcha/captcha.py index 8f0b828d8..6d4cd86e8 100644 --- a/captcha/captcha.py +++ b/captcha/captcha.py @@ -1,3 +1,4 @@ +import thread  #!/usr/bin/env python  # -*- coding: utf-8 -*-  # @@ -22,6 +23,29 @@ import tempfile  import Image  import ImageOps +import threading + +class RunThread(threading.Thread): +    def __init__(self): +        threading.Thread.__init__(self) + +    def e(self, command, inputdata=None): +        """execute command """ +        self.command = command +        self.inputdata = inputdata +        self.result = "" +        self.start() +        self.join(10) +        return self.result + +    def run(self): +        """Run a command and return standard output""" +        pipe = subprocess.PIPE +        popen = subprocess.Popen(self.command, stdout=pipe, stderr=pipe) +        outputdata, errdata = popen.communicate(self.inputdata) +        assert (popen.returncode == 0), \ +            "Error running: %s\n\n%s" % (self.command, errdata) +        self.result = outputdata  class OCR(object):      def __init__(self): @@ -41,12 +65,18 @@ class OCR(object):      def run(self, command, inputdata=None):          """Run a command and return standard output""" -        pipe = subprocess.PIPE -        popen = subprocess.Popen(command, stdout=pipe, stderr=pipe) -        outputdata, errdata = popen.communicate(inputdata) -        assert (popen.returncode == 0), \ -            "Error running: %s\n\n%s" % (command, errdata) -        return outputdata +#        OLD METHOD +#        pipe = subprocess.PIPE +#        popen = subprocess.Popen(command, stdout=pipe, stderr=pipe) +#        outputdata, errdata = popen.communicate(inputdata) +#        assert (popen.returncode == 0), \ +#            "Error running: %s\n\n%s" % (command, errdata) +#        return outputdata + +        thread = RunThread() +        result = thread.e(command, inputdata) +        print result +        return result      def run_gocr(self):          tmp = tempfile.NamedTemporaryFile(suffix=".jpg") | 
