Skip to content

Instantly share code, notes, and snippets.

@nikhilm
Created January 4, 2011 19:15
Show Gist options
  • Save nikhilm/765236 to your computer and use it in GitHub Desktop.
Save nikhilm/765236 to your computer and use it in GitHub Desktop.
# Simple script which runs code when a file is modified
#
# You will have to install pyinotify
#
# Run with the directory to watch
# eg. python autobuild.py ./
# currently hardcoded to use
#
# (c) 2009, Nikhil Marathe <[email protected]>
# Licensed under the MIT License
import sys
import os
import subprocess
import re
from pyinotify import WatchManager, Notifier, ProcessEvent, IN_MODIFY
wm = WatchManager()
class Compile( ProcessEvent ):
def process_IN_MODIFY( self, event ):
print event.path, event.name, event.mask & IN_MODIFY
# put custom code here
c = Compile()
notifier = Notifier( wm, c )
wm.add_watch( sys.argv[1], IN_MODIFY, rec=True )
notifier.loop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment