You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by dm...@apache.org on 2017/12/01 01:24:02 UTC
[tika] branch master updated: TIKA-2385: Added check for Python
dependencies
This is an automated email from the ASF dual-hosted git repository.
dmeikle pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tika.git
The following commit(s) were added to refs/heads/master by this push:
new 7a9411f TIKA-2385: Added check for Python dependencies
7a9411f is described below
commit 7a9411f9d06a667114f9ea67ad48f1099be1ec3b
Author: David Meikle <da...@logicalspark.com>
AuthorDate: Fri Dec 1 01:23:54 2017 +0000
TIKA-2385: Added check for Python dependencies
---
.../apache/tika/parser/ocr/TesseractOCRParser.java | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/tika-parsers/src/main/java/org/apache/tika/parser/ocr/TesseractOCRParser.java b/tika-parsers/src/main/java/org/apache/tika/parser/ocr/TesseractOCRParser.java
index 0b17393..b2ce47f 100644
--- a/tika-parsers/src/main/java/org/apache/tika/parser/ocr/TesseractOCRParser.java
+++ b/tika-parsers/src/main/java/org/apache/tika/parser/ocr/TesseractOCRParser.java
@@ -168,24 +168,26 @@ public class TesseractOCRParser extends AbstractParser implements Initializable
return hasImageMagick;
}
-
+
static boolean hasPython() {
- // check if python is installed, it has the required dependencies for the rotation program to run
+ // check if python is installed, it has the required dependencies for the rotation program to run
boolean hasPython = false;
- DefaultExecutor executor = new DefaultExecutor();
- CommandLine cmdLine = CommandLine.parse("python -c \"import numpy, matplotlib, skimage;\"");
+
try {
- int returnCode = executor.execute(cmdLine);
- if (returnCode != -1) {
+ String[] commands = {"python", "-c", "\"import numpy, matplotlib, skimage;\"" };
+
+ Process proc = Runtime.getRuntime().exec(commands);
+ BufferedReader stdInput = new BufferedReader(new InputStreamReader(proc.getInputStream(), "UTF-8"));
+ if(stdInput.read() != -1) {
hasPython = true;
}
+ } catch (IOException e) {
- } catch(Exception e) {
- // Do nothing
}
+
return hasPython;
}
-
+
public void parse(Image image, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException,
SAXException, TikaException {
TemporaryResources tmp = new TemporaryResources();
--
To stop receiving notification emails like this one, please contact
['"commits@tika.apache.org" <co...@tika.apache.org>'].