Skip to content

Commit

Permalink
Adding script to test watching changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Apr 13, 2013
1 parent 2275152 commit 3fe64da
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions scripts/watch-changes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from __future__ import print_function
import traceback
import sys
import logging

from jaraco.windows.filesystem import change

logging.basicConfig(level=logging.INFO)

def long_handler(file):
try:
with open(file, 'rb') as f:
data = f.read()
print("read", len(data), "bytes from", file)
except Exception:
traceback.print_exc()

def main():
try:
watch()
except KeyboardInterrupt:
pass

def watch():
notifier = change.BlockingNotifier(sys.argv[1])
notifier.watch_subtree=True

for ch in notifier.get_changed_files():
long_handler(ch)

if __name__ == '__main__':
main()

0 comments on commit 3fe64da

Please sign in to comment.