Skip to content

Instantly share code, notes, and snippets.

Created Jan 25, 2012
What would you like to do?
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:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment