diff options
Diffstat (limited to 'addons/document/content_index.py')
| -rw-r--r-- | addons/document/content_index.py | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/addons/document/content_index.py b/addons/document/content_index.py index b6f89604c3e..8c2c9209ced 100644 --- a/addons/document/content_index.py +++ b/addons/document/content_index.py @@ -23,8 +23,6 @@ import os import tempfile from subprocess import Popen, PIPE _logger = logging.getLogger(__name__) -class NhException(Exception): - pass class indexer(object): @@ -61,13 +59,13 @@ class indexer(object): try: if content != None: return self._doIndexContent(content) - except NhException: + except NotImplementedError: pass if realfile != None: try: return self._doIndexFile(realfile) - except NhException: + except NotImplementedError: pass fp = open(realfile,'rb') @@ -90,16 +88,16 @@ class indexer(object): res = self._doIndexFile(rfname) os.unlink(rfname) return res - except NhException: + except NotImplementedError: pass - raise NhException('No appropriate method to index file.') + raise ValueError('No appropriate method to index file.') def _doIndexContent(self, content): - raise NhException("Content cannot be handled here.") + raise NotImplementedError("Content cannot be handled here.") def _doIndexFile(self, fpath): - raise NhException("Content cannot be handled here.") + raise NotImplementedError("Content cannot be handled here.") def __repr__(self): return "<indexer %s.%s>" %(self.__module__, self.__class__.__name__) @@ -130,10 +128,9 @@ class contentIndex(object): self.exts[ext] = obj f = True - if f: - _logger.debug('Register content indexer: %r.', obj) if not f: - raise Exception("Your indexer should at least support a mimetype or extension.") + raise ValueError("Your indexer should at least support a mimetype or extension.") + _logger.debug('Register content indexer: %r.', obj) def doIndex(self, content, filename=None, content_type=None, realfname=None, debug=False): fobj = None @@ -174,7 +171,7 @@ class contentIndex(object): if not mime: mime = mime2 except Exception: - _logger.exception('Cannot determine mime type.') + _logger.info('Cannot determine mime type.', exc_info=True) try: if fobj: @@ -183,8 +180,8 @@ class contentIndex(object): _logger.debug("Have no object, return (%s, None).", mime) res = (mime, '') except Exception: - _logger.exception("Cannot index file %s (%s).", - filename, fname or realfname) + _logger.info("Cannot index file %s (%s).", + filename, fname or realfname, exc_info=True) res = (mime, '') # If we created a tmp file, unlink it now |
