Created
November 3, 2012 20:04
-
-
Save bryhal/4008534 to your computer and use it in GitHub Desktop.
PYTHON: FSMonitor skeleton - monitor folder(s) for changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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