When writing maps/reduce functions for couch, its tedious to make a change, jump to the server console, push the code, then call the map/reduce via a web browser or curl. So I figured, cut at least 1 step out of the whole process and just page back and forth from the IDE to the browser while a tail of the couchdb error log spins by on a 2nd monitor.
import os
from os import path
import time
from stat import ST_MTIME
manifest = dict()
import subprocess
while 1:
time.sleep(3)
print "Scanning"
for root , dirs, files in os.walk("./_design/"):
for file in files:
filepath = path.join(root,file)
mtime = os.stat(filepath)[ST_MTIME]
if not filepath in manifest:
manifest[filepath] = mtime
else:
if mtime > manifest[filepath]:
print filepath, "is stale, updating."
subprocess.call(["/usr/bin/python", "push.py"] )
manifest[filepath] = mtime