[MERGE] document: fixed bug 905279 : catching error when antiword not installed for doc file indexing
bzr revid: tde@openerp.com-20111219151001-rcj2qdji5a3z63k3
This commit is contained in:
commit
5a2d37d47c
|
@ -24,6 +24,7 @@ from subprocess import Popen, PIPE
|
||||||
import StringIO
|
import StringIO
|
||||||
import odt2txt
|
import odt2txt
|
||||||
import sys, zipfile, xml.dom.minidom
|
import sys, zipfile, xml.dom.minidom
|
||||||
|
import logging
|
||||||
|
|
||||||
def _to_unicode(s):
|
def _to_unicode(s):
|
||||||
try:
|
try:
|
||||||
|
@ -95,9 +96,15 @@ class DocIndex(indexer):
|
||||||
return ['.doc']
|
return ['.doc']
|
||||||
|
|
||||||
def _doIndexFile(self,fname):
|
def _doIndexFile(self,fname):
|
||||||
pop = Popen(['antiword', fname], shell=False, stdout=PIPE)
|
try:
|
||||||
(data, _) = pop.communicate()
|
pop = Popen(['antiword', fname], shell=False, stdout=PIPE)
|
||||||
return _to_unicode(data)
|
(data, _) = pop.communicate()
|
||||||
|
return _to_unicode(data)
|
||||||
|
except OSError:
|
||||||
|
logger = logging.getLogger('document.DocIndex')
|
||||||
|
logger.warn("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
|
||||||
|
|
||||||
cntIndex.register(DocIndex())
|
cntIndex.register(DocIndex())
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue