Home
DevCentral
Search
Configure Global Search
Log In
Transactions
P118
Change Details
Change Details
Old
New
Diff
#!/usr/bin/env python3 import json import os import sys # # Deployment methods # def deployExperiments (deploys, wwwroot): for deploy in deploys: deployExperiment(deploy, wwwroot) def deployExperiment (deploy, wwwroot): path = getDeployPath(deploy, wwwroot) if "repo" in deploy: branch = getDeployBranch(deploy) deployRepo(deploy["repo"], branch, path) else: createEmptyWebDirectory(path) def getDeployBranch(deploy): if "branch" in deploy: return deploy["branch"] else: return "master" def getDeployPath(deploy, wwwroot): if "path" in deploy: path = deploy["path"] else: if not "name" in deploy: raise KeyError("Name is missing from deploy.") path = deploy["name"] return os.path.join(wwwroot, path) def createEmptyWebDirectory(path): os.makedirs(path) def deployRepo(repo, branch, path): print("Deploy", repo, "at", branch, "to", path) # # Procedural code # # Parse argument if len(sys.argv) == 2: wwwroot = sys.argv[1] if not os.path.exists(wwwroot): createEmptyWebDirectory(wwwroot) if not os.path.isdir(wwwroot): print("Not a directory: " + wwwroot, file=sys.stderr) sys.exit(2) else: print("Usage:", sys.argv[0], "<web root directory to deploy>") sys.exit(1) # Reads deploy configuration file with open("conf/deploy.json", "r") as configDeployFile: data = configDeployFile.read() deploys = json.loads(data) # Deploy deployExperiments(deploys, wwwroot)
#!/usr/bin/env python3 import json import os import sys # # Deployment methods # def deployExperiments (deploys, wwwroot): for deploy in deploys: deployExperiment(deploy, wwwroot) def deployExperiment (deploy, wwwroot): path = getDeployPath(deploy, wwwroot) if "repo" in deploy: branch = getDeployBranch(deploy) deployRepo(deploy["repo"], branch, path) else: createEmptyWebDirectory(path) def getDeployBranch (deploy): if "branch" in deploy: return deploy["branch"] else: return "master" def getDeployPath (deploy, wwwroot): if "path" in deploy: path = deploy["path"] else: if not "name" in deploy: raise KeyError("Name is missing from deploy.") path = deploy["name"] return os.path.join(wwwroot, path) def createEmptyWebDirectory (path): os.makedirs(path) def deployRepo (repo, branch, path): print("Deploy", repo, "at", branch, "to", path) # # Procedural code # # Parse argument if len(sys.argv) == 2: wwwroot = sys.argv[1] if not os.path.exists(wwwroot): createEmptyWebDirectory(wwwroot) if not os.path.isdir(wwwroot): print("Not a directory: " + wwwroot, file=sys.stderr) sys.exit(2) else: print("Usage:", sys.argv[0], "<web root directory to deploy>") sys.exit(1) # Reads deploy configuration file with open("conf/deploy.json", "r") as configDeployFile: data = configDeployFile.read() deploys = json.loads(data) # Deploy deployExperiments(deploys, wwwroot)
#!/usr/bin/env python3 import json import os import sys # # Deployment methods # def deployExperiments (deploys, wwwroot): for deploy in deploys: deployExperiment(deploy, wwwroot) def deployExperiment (deploy, wwwroot): path = getDeployPath(deploy, wwwroot) if "repo" in deploy: branch = getDeployBranch(deploy) deployRepo(deploy["repo"], branch, path) else: createEmptyWebDirectory(path) def getDeployBranch
(deploy): if "branch" in deploy: return deploy["branch"] else: return "master" def getDeployPath
(deploy, wwwroot): if "path" in deploy: path = deploy["path"] else: if not "name" in deploy: raise KeyError("Name is missing from deploy.") path = deploy["name"] return os.path.join(wwwroot, path) def createEmptyWebDirectory
(path): os.makedirs(path) def deployRepo
(repo, branch, path): print("Deploy", repo, "at", branch, "to", path) # # Procedural code # # Parse argument if len(sys.argv) == 2: wwwroot = sys.argv[1] if not os.path.exists(wwwroot): createEmptyWebDirectory(wwwroot) if not os.path.isdir(wwwroot): print("Not a directory: " + wwwroot, file=sys.stderr) sys.exit(2) else: print("Usage:", sys.argv[0], "<web root directory to deploy>") sys.exit(1) # Reads deploy configuration file with open("conf/deploy.json", "r") as configDeployFile: data = configDeployFile.read() deploys = json.loads(data) # Deploy deployExperiments(deploys, wwwroot)
Continue