Skip to content

Instantly share code, notes, and snippets.

@bryhal
Created November 3, 2012 20:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bryhal/4008534 to your computer and use it in GitHub Desktop.
Save bryhal/4008534 to your computer and use it in GitHub Desktop.
PYTHON: FSMonitor skeleton - monitor folder(s) for changes
#!/usr/bin/env python
# depends on FSMonitor https://github.com/shaurz/fsmonitor
import sys
import os
def main():
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
from fsmonitor import FSMonitor
if len(sys.argv) < 2:
print "usage: dirwatch.py [DIRS...]"
sys.exit(1)
m = FSMonitor()
for arg in sys.argv[1:]:
m.add_dir_watch(arg)
while True:
for evt in m.read_events():
print "%s %s %s" % (evt.action_name, evt.watch.path, evt.name)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment