summaryrefslogtreecommitdiffstats
path: root/module/plugins/captcha/captcha.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-11-09 03:08:19 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-11-09 03:08:19 +0100
commitbd8259220ab4d56ab419b7b32045b08cc9b0a7c8 (patch)
tree92f1c69d4280f8f57021083dbf878e62033eb502 /module/plugins/captcha/captcha.py
parentCookie support for getURL method (diff)
downloadpyload-bd8259220ab4d56ab419b7b32045b08cc9b0a7c8.tar.xz
Use with statement instead open method when accessing fod + handle i/o error
Diffstat (limited to 'module/plugins/captcha/captcha.py')
-rw-r--r--module/plugins/captcha/captcha.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/module/plugins/captcha/captcha.py b/module/plugins/captcha/captcha.py
index 93c8164c6..e0cd7d31c 100644
--- a/module/plugins/captcha/captcha.py
+++ b/module/plugins/captcha/captcha.py
@@ -57,12 +57,17 @@ class OCR(object):
def run_tesser(self, subset=False, digits=True, lowercase=True, uppercase=True):
#tmpTif = tempfile.NamedTemporaryFile(suffix=".tif")
- tmpTif = open(join("tmp", "tmpTif_%s.tif" % self.__name__), "wb")
- tmpTif.close()
-
- #tmpTxt = tempfile.NamedTemporaryFile(suffix=".txt")
- tmpTxt = open(join("tmp", "tmpTxt_%s.txt" % self.__name__), "wb")
- tmpTxt.close()
+ try:
+ tmpTif = open(join("tmp", "tmpTif_%s.tif" % self.__name__), "wb")
+ tmpTif.close()
+
+ #tmpTxt = tempfile.NamedTemporaryFile(suffix=".txt")
+ tmpTxt = open(join("tmp", "tmpTxt_%s.txt" % self.__name__), "wb")
+ tmpTxt.close()
+
+ except IOError, e:
+ self.logError(str(e))
+ return
self.logger.debug("save tiff")
self.image.save(tmpTif.name, 'TIFF')