Commit 966a81a3 authored by Leonardo Rochael Almeida's avatar Leonardo Rochael Almeida Committed by Julien Muchembled

Report more information when tesseract fails

parent 01e71ab1
...@@ -4,6 +4,7 @@ from Products.PortalTransforms.data import datastream ...@@ -4,6 +4,7 @@ from Products.PortalTransforms.data import datastream
from Products.PortalTransforms.libtransforms.commandtransform \ from Products.PortalTransforms.libtransforms.commandtransform \
import commandtransform import commandtransform
import os import os
import subprocess
import tempfile import tempfile
from zope.interface import implements from zope.interface import implements
...@@ -30,11 +31,21 @@ class tiff_to_text(commandtransform): ...@@ -30,11 +31,21 @@ class tiff_to_text(commandtransform):
text = None text = None
try: try:
command = self.binary
output_file_path = os.path.join(tmp_dir, 'output') output_file_path = os.path.join(tmp_dir, 'output')
cmd = '%s %s %s' % ( cmd = self.binary, input_file, output_file_path
self.binary, input_file, output_file_path) process = subprocess.Popen(cmd,
os.system(cmd) stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,)
stdout = process.communicate()[0]
err = process.returncode
if err:
if err < 0:
exit_msg = 'killed with signal %s' % -err
else:
exit_msg = 'exited with status %s' % err
raise EnvironmentError('Command %r %s. Command output:\n%s'
% (cmd, exit_msg, stdout))
output_file = open(output_file_path + '.txt', 'r') output_file = open(output_file_path + '.txt', 'r')
out = output_file.read() out = output_file.read()
output_file.close() output_file.close()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment