class DeepSearchHandler(pyinotify.ProcessEvent): """ Deep file search handler to handle the events gengerated by file changes """ def __init__(self): self.datahandler = DatabaseHandler() print "instance created" def process_IN_CREATE(self, event): """Called when a file or directory is created.""" print "file create event" + str(event) self.datahandler.create(event.pathname) def process_IN_MODIFY(self, event): """"Called when a file or directory is modified.""" print "file modify event" + str(event) self.datahandler.update(event.pathname) def process_IN_DELETE(self, event): """" Called when a file or directory is deleted. """ print "file delete event" + str(event) self.datahandler.delete(event.pathname) def process_IN_ACCESS(self, event): """" Called when a file or directory is accessed. """ print "file access event" + str(event.pathname) self.datahandler.access(event.pathname) def close_db_connection(self): """ call close_connection function of datanadler """ self.datahandler.close_connection()
class DeepSearchHandler(PatternMatchingEventHandler): """ Deep file search handler to handle the events gengerated by file changes """ def __init__(self): self.datahandler = DatabaseHandler() self._ignore_directories = False self._ignore_patterns = False self._ignore_patterns = ["*.log","*.logger"] self._case_sensitive = False self._patterns = ["*.rb","*.py","*.java","*.mp4","*.mp3","*.txt"] print "instance created" def on_created(self,event): """Called when a file or directory is created.""" print "file create event"+str(event) self.datahandler.create(event.src_path) def on_modified(self,event): """"Called when a file or directory is modified.""" print "file modify event"+str(event) self.datahandler.update(event.src_path) def on_deleted(self,event): """" Called when a file or directory is deleted. """ print "file delete event"+str(event) self.datahandler.delete(event.src_path) def on_moved(self,event): """"Called when a file or a directory is moved or renamed.""" print "file moved event"+str(event) self.datahandler.moved(event.src_path) def close_db_connection(self): """ call close_connection function of datanadler """ self.datahandler.close_connection()