Created
January 4, 2011 19:15
-
-
Save nikhilm/765236 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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