Beispiel #1
0
 def clear_index_directory(self):
     """Removes the indexed contents
     """
     if self.path and self._path.startswith(settings.INDEXES_PATH):
         os.system('rm -rf %s' % self.path)
         log.warning('removed index at %s' % self.path)
     pass
Beispiel #2
0
 def clear_index_directory(self):
     """Removes the indexed contents
     """
     if self.path and self._path.startswith(settings.INDEXES_PATH):
         os.system('rm -rf %s' % self.path)
         log.warning('removed index at %s' % self.path)
     pass
Beispiel #3
0
 def __index_path(self, path):
     """Indexes the items at the specified path."""
     if os.path.isdir(path):
         self.__index_dir(path)
     elif os.path.isfile(path):
         self.__index_file(path)
     else:
         msg = 'Path %s is not valid for indexing' % path
         log.warning(msg)
         raise Exception(msg)
Beispiel #4
0
 def __index_path(self, path):
     """Indexes the items at the specified path."""
     if os.path.isdir(path):
         self.__index_dir(path)
     elif os.path.isfile(path):
         self.__index_file(path)
     else:
         msg = "Path %s is not valid for indexing" % path
         log.warning(msg)
         raise Exception(msg)
Beispiel #5
0
    def __init__(self, hit, indexer, **kwargs):
        """Initializes this Result instance.

        :param hit: The raw indexer search hit this instance represents
        :param indexer: The sherlock.Indexer that holds this search result
        @param kwargs {
            path = Path of the file this result represents
            filename = Filename of the file
        }
        """
        # the textual context of the hit
        self.context = ''
        self.path = kwargs.get('path')
        self.filename = kwargs.get('filename')
        self.index_path = self.path.replace(FULL_INDEX_PATH, '')
        try:
            self.process_hit(hit)
        except IOError, e:
            logger.warning('IOError while processing hit: %s:%s', self.path, e)
Beispiel #6
0
 def __init__(self, hit, indexer, **kwargs):
     """Initializes this Result instance
     :param hit: The raw indexer search hit this instance represents
     :param indexer: The sherlock.Indexer that holds this search result
     @param kwargs {
         path = Path of the file this result represents
         filename = Filename of the file
     }
     """
     # the textual context of the hit
     self.context = ''
     self.path = kwargs.get('path')
     self.filename = kwargs.get('filename')
     self.index_path = self.path.replace(FULL_INDEX_PATH, '')
     try:
         self.process_hit(hit)
     except IOError, e:
         logger.warning('IOError while processing hit: %s:%s' % (self.path, e))
         pass
Beispiel #7
0
 def open(self, index_path, **kwargs):
     """Creates or opens an index at the specified path."""
     if not os.path.isdir(index_path):
         msg = 'Directory `%s` is not a valid index directory.' % index_path
         log.warning(msg)
         raise Exception(msg)
     # create the dir, if needed
     path = os.path.join(index_path, self._name)
     if not os.path.isdir(path):
         os.mkdir(path)
         log.warning('created index directory at %s' % path)
     # create or open the index
     if self._rebuild_index or not self._index.index_exists(path):
         log.debug('creating index at %s' % path)
         self._index.create_index(path)
     else:
         log.debug('opening index at %s' % path)
         self._index.open_index(path, writable=self._is_writable)
     # store indexes path
     self._path = path
Beispiel #8
0
 def open(self, index_path, **kwargs):
     """Creates or opens an index at the specified path."""
     if not os.path.isdir(index_path):
         msg = "Directory `%s` is not a valid index directory." % index_path
         log.warning(msg)
         raise Exception(msg)
     # create the dir, if needed
     path = os.path.join(index_path, self._name)
     if not os.path.isdir(path):
         os.mkdir(path)
         log.warning("created index directory at %s" % path)
     # create or open the index
     if self._rebuild_index or not self._index.index_exists(path):
         log.debug("creating index at %s" % path)
         self._index.create_index(path)
     else:
         log.debug("opening index at %s" % path)
         self._index.open_index(path, writable=self._is_writable)
     # store indexes path
     self._path = path
Beispiel #9
0
 def clear_index_directory(self):
     """Removes the indexed contents."""
     if self.path and self._path.startswith(settings.INDEXES_PATH):
         shutil.rmtree(self.path)
         log.warning('removed index at %s' % self.path)
Beispiel #10
0
 def clear_index_directory(self):
     """Removes the indexed contents."""
     if self.path and self._path.startswith(settings.INDEXES_PATH):
         shutil.rmtree(self.path)
         log.warning("removed index at %s" % self.path)