From c38dad2b213d5c2100244cb87cfc53a6cbac4509 Mon Sep 17 00:00:00 2001 From: Edward Ribeiro Date: Tue, 23 May 2017 18:08:05 -0300 Subject: [PATCH] =?UTF-8?q?Captura=20erro=20de=20indexa=C3=A7=C3=A3o=20de?= =?UTF-8?q?=20arquivo.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/base/search_indexes.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sapl/base/search_indexes.py b/sapl/base/search_indexes.py index 58e1688c4..61fe3438a 100644 --- a/sapl/base/search_indexes.py +++ b/sapl/base/search_indexes.py @@ -32,10 +32,7 @@ class DocumentoAcessorioIndex(indexes.SearchIndex, indexes.Indexable): arquivo = getattr(obj, self.filename) if arquivo: - try: - arquivo.open() - arquivo.close() - except OSError: + if not os.path.exists(arquivo.path): return self.prepared_data if not os.path.splitext(arquivo.path)[1][:1]: @@ -43,10 +40,13 @@ class DocumentoAcessorioIndex(indexes.SearchIndex, indexes.Indexable): try: extracted_data = textract.process( - arquivo.path).decode( - 'utf-8').replace('\n', ' ') + arquivo.path, + language='pt-br').decode('utf-8').replace('\n', ' ') except ExtensionNotSupported: return self.prepared_data + except Exception: + print('Erro inesperado processando arquivo: %s' % arquivo.path) + return self.prepared_data extracted_data = extracted_data.replace('\t', ' ')