Skip to content

Instantly share code, notes, and snippets.

@steveandroulakis
Created September 25, 2012 02:16
Show Gist options
  • Save steveandroulakis/3779591 to your computer and use it in GitHub Desktop.
Save steveandroulakis/3779591 to your computer and use it in GitHub Desktop.
CherryPy server script
import cherrypy
import subprocess
import os
git_cmd = "/usr/local/git/bin/git"
jekyll_cmd = "/opt/local/bin/jekyll"
swift_cmd = "/usr/local/bin/swift"
site_dir = "_site" #/Users/steve/Documents/git/tjdett/uberdojo-cms/
swift_container = "steve-dojo"
os_auth_url = "http://keystone.rc.nectar.org.au:5000/v2.0/"
os_username = "Steve.Androulakis@monash.edu"
os_password = "yeahhhhh"
os_tenant_name = "Dojo"
os_tenant_id = "36c4c535b77a4795992b3f907f797929"
# designed to be triggered by github post-commit. updates github repo, runs jekyll to generate pages and uploads to a swift object store
class GenerateSite(object):
def index(self):
output = ""
cmd = git_cmd + " pull"
output += subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True).stdout.read()
cmd = jekyll_cmd
output += subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True).stdout.read()
# awesomest command ever
cmd = swift_cmd + " upload " + swift_container + " " + site_dir + \
" --os-auth-url " + os_auth_url + " --os-username " + os_username + \
" --os-password " + os_password + " --os-tenant-name " + os_tenant_name + " --os-tenant-id " + \
os_tenant_id
output += subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True).stdout.read()
return output
index.exposed = True
cherrypy.quickstart(GenerateSite())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment