[MERGE] OPW 587184: Document: Graceful handling of the case when pdftotext is not installed and an index needs to be generated.

bzr revid: cbi@openerp.com-20130307090434-2anmh0mh0dbz38q0
This commit is contained in:
Chris Biersbach 2013-03-07 10:04:34 +01:00
commit ae410ff044
2 changed files with 11 additions and 6 deletions

View File

@ -181,11 +181,11 @@ class contentIndex(object):
res = (mime, fobj.indexContent(content,filename,fname or realfname) )
else:
_logger.debug("Have no object, return (%s, None).", mime)
res = (mime, None )
res = (mime, '')
except Exception:
_logger.exception("Cannot index file %s (%s).",
filename, fname or realfname)
res = None
res = (mime, '')
# If we created a tmp file, unlink it now
if not realfname and fname:

View File

@ -105,7 +105,7 @@ class DocIndex(indexer):
_logger.warning("Failed attempt to execute antiword (MS Word reader). Antiword is necessary to index the file %s of MIME type %s. Detailed error available at DEBUG level.", fname, self._getMimeTypes()[0])
_logger.debug("Trace of the failed file indexing attempt.", exc_info=True)
return False
return u''
cntIndex.register(DocIndex())
@ -166,9 +166,14 @@ class PdfIndex(indexer):
return ['.pdf']
def _doIndexFile(self, fname):
pop = Popen(['pdftotext', '-enc', 'UTF-8', '-nopgbrk', fname, '-'], shell=False, stdout=PIPE)
(data, _) = pop.communicate()
return _to_unicode(data)
try:
pop = Popen(['pdftotext', '-enc', 'UTF-8', '-nopgbrk', fname, '-'], shell=False, stdout=PIPE)
(data, _) = pop.communicate()
return _to_unicode(data)
except OSError:
_logger.warning("Failed attempt to execute pdftotext. This program is necessary to index the file %s of MIME type %s. Detailed error available at DEBUG level.", fname, self._getMimeTypes()[0])
_logger.debug("Trace of the failed file indexing attempt.", exc_info=True)
return u''
cntIndex.register(PdfIndex())