Skip to content

Instantly share code, notes, and snippets.

@vsajip
Created Jan 25, 2012
Embed
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:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment