Merge remote-tracking branch 'origin/develop' into develop

pull/4797/head
Weblate 2017-07-20 10:02:15 +00:00
commit 055224693a
2 changed files with 24 additions and 13 deletions

View File

@ -63,7 +63,8 @@ class Deployer:
self.packages_path = "." self.packages_path = "."
self.bundles_path = None self.bundles_path = None
self.should_clean = False self.should_clean = False
self.config_location = None # filename -> symlink path e.g 'config.localhost.json' => '../localhost/config.json'
self.config_locations = {}
self.verify_signature = True self.verify_signature = True
def deploy(self, tarball, extract_path): def deploy(self, tarball, extract_path):
@ -95,11 +96,12 @@ class Deployer:
print ("Extracted into: %s" % extracted_dir) print ("Extracted into: %s" % extracted_dir)
if self.config_location: if self.config_locations:
create_relative_symlink( for config_filename, config_loc in self.config_locations.iteritems():
target=self.config_location, create_relative_symlink(
linkname=os.path.join(extracted_dir, 'config.json') target=config_loc,
) linkname=os.path.join(extracted_dir, config_filename)
)
if self.bundles_path: if self.bundles_path:
extracted_bundles = os.path.join(extracted_dir, 'bundles') extracted_bundles = os.path.join(extracted_dir, 'bundles')
@ -178,6 +180,8 @@ if __name__ == "__main__":
deployer.packages_path = args.packages_dir deployer.packages_path = args.packages_dir
deployer.bundles_path = args.bundles_dir deployer.bundles_path = args.bundles_dir
deployer.should_clean = args.clean deployer.should_clean = args.clean
deployer.config_location = args.config deployer.config_locations = {
"config.json": args.config,
}
deployer.deploy(args.tarball, args.extract_path) deployer.deploy(args.tarball, args.extract_path)

View File

@ -185,10 +185,16 @@ if __name__ == "__main__":
to the /vector directory INSIDE the tarball." to the /vector directory INSIDE the tarball."
) )
) )
def _raise(ex):
raise ex
# --config config.json=../../config.json --config config.localhost.json=./localhost.json
parser.add_argument( parser.add_argument(
"--config", dest="config", help=( "--config", action="append", dest="configs",
"Write a symlink to config.json in the extracted tarball. \ type=lambda kv: kv.split("=", 1) if "=" in kv else _raise(Exception("Missing =")), help=(
To this location." "A list of configs to symlink into the extracted tarball. \
For example, --config config.json=../config.json config2.json=../test/config.json"
) )
) )
parser.add_argument( parser.add_argument(
@ -212,7 +218,8 @@ if __name__ == "__main__":
deployer = Deployer() deployer = Deployer()
deployer.bundles_path = args.bundles_dir deployer.bundles_path = args.bundles_dir
deployer.should_clean = args.clean deployer.should_clean = args.clean
deployer.config_location = args.config deployer.config_locations = dict(args.configs) if args.configs else {}
# we don't pgp-sign jenkins artifacts; instead we rely on HTTPS access to # we don't pgp-sign jenkins artifacts; instead we rely on HTTPS access to
# the jenkins server (and the jenkins server not being compromised and/or # the jenkins server (and the jenkins server not being compromised and/or
@ -225,13 +232,13 @@ if __name__ == "__main__":
deploy_tarball(args.tarball_uri, build_dir) deploy_tarball(args.tarball_uri, build_dir)
else: else:
print( print(
"Listening on port %s. Extracting to %s%s. Symlinking to %s. Jenkins URL: %s. Config location: %s" % "Listening on port %s. Extracting to %s%s. Symlinking to %s. Jenkins URL: %s. Config locations: %s" %
(args.port, (args.port,
arg_extract_path, arg_extract_path,
" (clean after)" if deployer.should_clean else "", " (clean after)" if deployer.should_clean else "",
arg_symlink, arg_symlink,
arg_jenkins_url, arg_jenkins_url,
deployer.config_location, deployer.config_locations,
) )
) )
app.run(host="0.0.0.0", port=args.port, debug=True) app.run(host="0.0.0.0", port=args.port, debug=True)