Skip to content

Instantly share code, notes, and snippets.

@omarkj
Created November 19, 2010 20:07
Show Gist options
  • Save omarkj/707068 to your computer and use it in GitHub Desktop.
Save omarkj/707068 to your computer and use it in GitHub Desktop.
Deploy multiple couchapps
#!/usr/bin/env python
# encoding: utf-8
import sys, getopt, subprocess, os
help_message = '''
Usage: deploy_all
\t-s server_name
\t-c couchapp exec'''
class Usage(Exception):
def __init__(self, msg):
self.msg = msg
def main(argv=None):
couchapp = "couchapp"
server_name = "default"
if argv is None:
argv = sys.argv
try:
try:
opts, args = getopt.getopt(argv[1:], "hc:s:")
except getopt.error, msg:
raise Usage(msg)
for option, value in opts:
if option in ("-h"):
raise Usage(help_message)
if option in ("-c"):
couchapp = value
if option in ("-s"):
server_name = value
do_deploy(couchapp, server_name)
except Usage, err:
print >> sys.stderr, sys.argv[0].split("/")[-1] + ": " + str(err.msg)
print >> sys.stderr, "\t-h for help"
return 2
def do_deploy(couchapp, servername):
# Check how many folders we have going on here
dirs = os.listdir(".")
for d in dirs:
if os.path.isdir(d):
if ".couchapprc" in os.listdir(d):
print("Deploying %s" % d)
result = subprocess.call([couchapp, "push", servername], cwd=d)
print("Done")
if __name__ == "__main__":
sys.exit(main())
@omarkj
Copy link
Author

omarkj commented Nov 19, 2010

I use this because I have one couchapp for each design document, and I have a few of those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment