Created
July 27, 2011 15:04
-
-
Save timothyekl/1109556 to your computer and use it in GitHub Desktop.
Recompile .tex files based on inotify from Python
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
import pyinotify | |
import os | |
import sys | |
class Handler(pyinotify.ProcessEvent): | |
def process_IN_MODIFY(self, event): | |
if event.name.endswith('.tex'): | |
print "Recompiling " + event.name + "..." | |
os.popen('pdflatex ' + event.name).read() | |
wm = pyinotify.WatchManager() | |
notifier = pyinotify.Notifier(wm, Handler()) | |
wm.add_watch(os.getcwd(), pyinotify.IN_MODIFY) | |
try: | |
notifier.loop() | |
except pyinotify.NotifierError, err: | |
print >>sys.stderr, err |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment