Skip to content

Instantly share code, notes, and snippets.

@vsajip
Created January 25, 2012 10:12
Show Gist options
  • Save vsajip/1675730 to your computer and use it in GitHub Desktop.
Save vsajip/1675730 to your computer and use it in GitHub Desktop.
doc-watch file system watcher for Windows (IronPython)
import clr
import os
from System.IO import FileSystemWatcher, NotifyFilters
stop = False
def on_change(source, e):
global stop
if not e.Name.endswith('.html'):
stop = True
print('%s: %s, stop = %s' % (e.FullPath, e.ChangeType, stop))
watcher = FileSystemWatcher(os.getcwd())
watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName
watcher.EnableRaisingEvents = True
watcher.IncludeSubdirectories = True
watcher.Changed += on_change
watcher.Created += on_change
while not stop:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment