diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-08-25 00:14:17 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-08-25 00:14:17 +0200 |
commit | f33f78e2bbcdc2847fb0811c9bce8747be4bdd60 (patch) | |
tree | 3d22b05ed2adc5ba31225de9cf05b06f8d92ced7 | |
parent | change configpath with setup, parser use plugins in homedir (diff) | |
download | pyload-f33f78e2bbcdc2847fb0811c9bce8747be4bdd60.tar.xz |
slightly improved process call
-rw-r--r-- | module/plugins/captcha/captcha.py | 38 |
1 files changed, 5 insertions, 33 deletions
diff --git a/module/plugins/captcha/captcha.py b/module/plugins/captcha/captcha.py index 60705f9e8..d8c2aa38d 100644 --- a/module/plugins/captcha/captcha.py +++ b/module/plugins/captcha/captcha.py @@ -32,27 +32,7 @@ import PngImagePlugin import GifImagePlugin import JpegImagePlugin -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 +from module.web.ServerThread import Output class OCR(object): @@ -74,18 +54,10 @@ class OCR(object): self.image = self.image.point(lambda a: a * value + 10) def run(self, command, inputdata=None): - """Run a command and return standard output""" - # 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) - return result + """Run a command""" + + popen = subprocess.Popen(command, bufsize = -1, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + popen.wait() def run_tesser(self, subset=False, digits=True, lowercase=True, uppercase=True): #self.logger.debug("create tmp tif") |