From 0397468a05569c330aa575ddb80263e45c2f92e2 Mon Sep 17 00:00:00 2001 From: "atp (Open ERP)" Date: Fri, 12 Nov 2010 15:44:16 +0530 Subject: [IMP]: Improve search view of Task hours report of project_timesheet module and file descriptor close() in document module. bzr revid: atp@tinyerp.co.in-20101112101416-51opsl6u147argqm --- addons/document/std_index.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'addons/document/std_index.py') diff --git a/addons/document/std_index.py b/addons/document/std_index.py index 2a588a017c1..7cfcd36e2dc 100644 --- a/addons/document/std_index.py +++ b/addons/document/std_index.py @@ -96,8 +96,13 @@ class DocIndex(indexer): def _doIndexFile(self,fname): fp = Popen(['antiword', fname], shell=False, stdout=PIPE).stdout - return _to_unicode(fp.read()) - + try: + file_data = _to_unicode(fp.read()) + finally: + fp.close() + + return file_data + cntIndex.register(DocIndex()) class DocxIndex(indexer): @@ -158,7 +163,12 @@ class PdfIndex(indexer): def _doIndexFile(self,fname): fp = Popen(['pdftotext', '-enc', 'UTF-8', '-nopgbrk', fname, '-'], shell=False, stdout=PIPE).stdout - return _to_unicode( fp.read()) + try: + file_data = _to_unicode( fp.read()) + finally: + fp.close() + + return file_data cntIndex.register(PdfIndex()) -- cgit v1.2.3