Example #1
0
class singleFileWatcher(LoggingEventHandler):
    '''
    This class enters all file 'created' events to a database pointed to by dbFolder
    '''
    def __init__(self, pathStructure, dbFolder):
        super(LoggingEventHandler, self).__init__()
        self.pathStructure = pathStructure
        self.dataStore = DataStore(dbFolder)

    def on_created(self, event):

        for ignoreFile in ['.DS_Store', 'Thumbs.db']:
            if ignoreFile in os.path.abspath(event.src_path):
                info = 'File ignored: ' + os.path.abspath(event.src_path)
                logging.debug(info)
                return

        info = 'On created: ' + os.path.abspath(event.src_path)
        logging.debug(info)

        if os.path.isdir(os.path.abspath(event.src_path)):
            info = 'Directory analysis is not available'
            logging.debug(info)
            return

        self.dataStore.addFileToDatabase(os.path.abspath(event.src_path))
        info = 'adding ' + event.src_path + ' to the database'
        logging.debug(info)
Example #2
0
class singleFileWatcher(LoggingEventHandler):
    '''
    This class enters all file 'created' events to a database pointed to by dbFolder
    '''
    def __init__(self, pathStructure, dbFolder):
        super(LoggingEventHandler, self).__init__()
        self.pathStructure = pathStructure
        self.dataStore = DataStore(dbFolder) 

    def on_created(self, event):
        
        for ignoreFile in ['.DS_Store', 'Thumbs.db']:
            if ignoreFile in os.path.abspath(event.src_path):
                info = 'File ignored: ' +  os.path.abspath(event.src_path)
                logging.debug(info)
                return

        info = 'On created: ' +  os.path.abspath(event.src_path)
        logging.debug(info)

        if os.path.isdir(os.path.abspath(event.src_path)):
            info = 'Directory analysis is not available'
            logging.debug(info)
            return

        self.dataStore.addFileToDatabase(os.path.abspath(event.src_path))
        info = 'adding ' + event.src_path + ' to the database'
        logging.debug(info)