Skip to content

Instantly share code, notes, and snippets.

@systempuntoout
Created August 31, 2010 12:54
Show Gist options
  • Save systempuntoout/558970 to your computer and use it in GitHub Desktop.
Save systempuntoout/558970 to your computer and use it in GitHub Desktop.
from fsevents import Observer
from fsevents import Stream
from datetime import datetime
import subprocess
import os
import time
PROJECT_PATH = '/Users/.../Project/GoogleAppEngine/stackprinter/'
TEMPLATE_COMPILE_PATH = os.path.join(PROJECT_PATH,'web','template.py')
VIEWS_PATH = os.path.join(PROJECT_PATH,'app','views')
def callback(event):
if event.name.endswith('.html'):
subprocess.Popen('python2.5 %s %s %s' % ( TEMPLATE_COMPILE_PATH ,'--compile', VIEWS_PATH) , shell=True)
print '%s - %s compiled!' % (datetime.now(), event.name.split('/')[-1])
observer = Observer()
observer.start()
stream = Stream(callback, VIEWS_PATH, file_events=True)
observer.schedule(stream)
while not observer.isAlive():
time.sleep(0.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment