Beispiel #1
0
    def scanfiles(self):
        """
        scans and caches all configured report locations
        """
        logging.debug("File Scan Starting")
        if self._filescan_thread.finished.is_set():
            logging.warning("Scan still busy, not starting now")
            return
        
        if not pickleScanRead:
            logging.info("Scanning Report locations")
            newcache = []
            for directory, filters in reportconfig.filterindex.iteritems():
                if os.path.exists(directory):
                    scandir = scan.getFiles(directory, filters)
                    newcache.extend(scandir)
                else:
                    logging.warning("directory not found: % s" % directory)
        else:
            path = os.path.dirname(os.path.abspath(__file__))
            filename = os.path.join(path, 'filescan2.pickle')
            logging.info("Reading Scan Pickle file %s" % filename)
            output = open(filename, 'rb')
            newcache = cPickle.load(output)            
        
        logging.info("Scanning complete")
        
        if pickleScan:
            filename = os.path.abspath('./filescan2.pickle')
            logging.info("Saving filescan cache to %s" % filename)
            output = open(filename, 'wb')
            cPickle.dump(newcache, output, 2)

        self._filescan_lock.acquire()
        logging.info("Updating Cache")
        self._filescan_cache = newcache
        self._filescan_cache_latest = self._getLatest()
        
        self._filescan_lock.release()
            
        logging.info("Scan complete")    
        logging.debug("Setup next scan in %s seconds", self.FILESCAN_INTERVAL)
        self._filescan_thread = threading.Timer(self.FILESCAN_INTERVAL, self.scanfiles) 
Beispiel #2
0
    def scanfiles(self):
        """
        scans and caches all configured report locations
        """
        logging.debug("File Scan Starting")
        
        if not options.options.pickle_scan_read:
            logging.info("Scanning Report locations")
            newcache = []
            for directory, filters in self.filterindex.iteritems():
                if os.path.exists(directory):
                    scandir = scan.getFiles(self, directory, filters)
                    newcache.extend(scandir)
                else:
                    logging.warning("directory not found: % s" % directory)
        else:
            path = os.path.dirname(os.path.abspath(__file__))
            filename = os.path.join(path, 'filescan2.pickle')
            logging.info("Reading Scan Pickle file %s" % filename)
            output = open(filename, 'rb')
            newcache = cPickle.load(output)            
        
        logging.info("Scanning complete")
        
        if pickleScan:
            filename = os.path.abspath('./filescan2.pickle')
            logging.info("Saving filescan cache to %s" % filename)
            output = open(filename, 'wb')
            cPickle.dump(newcache, output, 2)

        logging.info("Updating Cache")
        self._filescan_cache = newcache
        self._filescan_cache_latest = self._getLatest()
                    
        logging.info("Scan complete")            
        ioloop.IOLoop.instance().add_timeout(datetime.timedelta(seconds=60), self.scanfiles)