Skip to content

Instantly share code, notes, and snippets.

@bbinet
Created May 5, 2012 13:01
Show Gist options
  • Save bbinet/2602183 to your computer and use it in GitHub Desktop.
Save bbinet/2602183 to your computer and use it in GitHub Desktop.
ebenezer-ghp-update cgi
#!/usr/bin/env python
import cgi
import os
import sys
if os.environ["REMOTE_ADDR"] in ["207.97.227.253", "50.57.128.197",
"108.171.174.178", "89.88.161.33"]:
print "Content-type: text/plain"
print ""
cmd = "bash -c 'export HOME=/home/data" \
"&& source /home/data/.venvburrito/startup.sh" \
"&& workon ebenezer-bf.org" \
"&& cd /home/data/dev/ghp-update/ebenezer-bf.org/" \
"&& ../pull_and_ghpimport.sh _output \"make html\"'"
execution = os.popen(cmd, 'r', 0)
output = "".join(execution.readlines())
execution.close()
print output
else:
print "Status: 403 Forbidden"
print ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment