Created
November 19, 2010 20:07
-
-
Save omarkj/707068 to your computer and use it in GitHub Desktop.
Deploy multiple couchapps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I use this because I have one couchapp for each design document, and I have a few of those.