Skip to content

Instantly share code, notes, and snippets.

@pixyj
Created February 6, 2014 09:22
Show Gist options
  • Save pixyj/8840963 to your computer and use it in GitHub Desktop.
Save pixyj/8840963 to your computer and use it in GitHub Desktop.
Seed file for listening to filesystem changes using python watchdog
import os
import time
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
class VHandler(FileSystemEventHandler):
def __init__(self):
FileSystemEventHandler.__init__(self)
def on_any_event(self, event):
print event
def start(path):
observer = Observer()
event_handler = VHandler()
observer.schedule(event_handler, path, recursive=True)
observer.start()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()
print "Bye\n"
if __name__ =="__main__":
path = os.getcwd()
start(path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment