From 8accec9b88caa24c9808d6fc5e70de0d968de2b1 Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Wed, 23 Sep 2020 19:50:49 +0200 Subject: [PATCH] rclocrtesseract: unquote tesseractcmd parameter and check existence. --- src/filters/rclocrtesseract.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/filters/rclocrtesseract.py b/src/filters/rclocrtesseract.py index 0dce9277..d2d77802 100755 --- a/src/filters/rclocrtesseract.py +++ b/src/filters/rclocrtesseract.py @@ -80,13 +80,19 @@ def ocrpossible(config, path): global tesseractcmd if not tesseractcmd: config.setKeyDir(os.path.dirname(path)) - tesseractcmd = config.getConfParam("tesseractcmd") + # It is very tempting to quote this value, esp. on Windows where it + # will contain whitespace. There is no chance that an actual command + # line would have quotes, so unquote it. + tesseractcmd = config.getConfParam("tesseractcmd").strip('"') if not tesseractcmd: tesseractcmd = rclexecm.which("tesseract") if not tesseractcmd: _deb("tesseractcmd not found") return False - + if not os.path.isfile(tesseractcmd): + _deb("tesseractcmd parameter [%s] is not a file" % tesseractcmd) + return False + # Check input format base,ext = os.path.splitext(path) ext = ext.lower()