aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Copeland <ben.copeland@linaro.org>2017-10-24 15:03:56 +0100
committerBen Copeland <ben.copeland@linaro.org>2017-10-24 15:03:56 +0100
commitab6b568fa54e2d84c12b6a220fa9543890faabb3 (patch)
tree1da7c4559fb7778c04cc59579083c847c60d8e7a
parente2b3bfb963f54a3a4e5f23b06f54e51b0a3c2bd3 (diff)
downloadci-yadp-builder-ab6b568fa54e2d84c12b6a220fa9543890faabb3.tar.gz
Fix Flake8 errors
-rwxr-xr-xyadp_builder.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/yadp_builder.py b/yadp_builder.py
index 54af588..d3f73c4 100755
--- a/yadp_builder.py
+++ b/yadp_builder.py
@@ -5,6 +5,7 @@ from jinja2 import FileSystemLoader, Environment
import jenkins
import logging
+
class LoaderMeta(type):
def __new__(metacls, __name__, __bases__, __dict__):
@@ -44,19 +45,22 @@ class Loader(yaml.Loader, metaclass=LoaderMeta):
else:
return ''.join(f.readlines())
+
def jinja2_from_template(directory, template_name, data):
loader = FileSystemLoader(directory)
env = Environment(loader=loader)
template = env.get_template(template_name)
return template.render(hosts=data)
+
def get_parser():
parser = argparse.ArgumentParser()
parser.add_argument('-u', '--username', type=str, required=True,
help='Username for Jenkins server')
parser.add_argument('-p', '--password', type=str, required=True,
help='Password for Jenkins server')
- parser.add_argument('-s', '--server', type=str, default='http://localhost:8080',
+ parser.add_argument('-s', '--server', type=str,
+ default='http://localhost:8080',
help='Jenkins server URL')
parser.add_argument('-i', '--inventory', type=str, default='hosts.yml',
help='specify inventory host path')
@@ -66,6 +70,7 @@ def get_parser():
help='Do not publish to Jenkins')
return parser
+
if __name__ == '__main__':
parser = get_parser()
args = parser.parse_args()
@@ -73,12 +78,17 @@ if __name__ == '__main__':
with open(args.inventory, 'r') as f:
data = yaml.load(f, Loader)
logging.debug(data)
- template_output = jinja2_from_template('./templates', 'configure-yadocker-cloud.groovy.j2', data)
- server = jenkins.Jenkins(args.server, username=args.username, password=args.password)
+ template_output = jinja2_from_template(
+ './templates',
+ 'configure-yadocker-cloud.groovy.j2', data)
+ server = jenkins.Jenkins(args.server, username=args.username,
+ password=args.password)
if args.dryrun:
with open('/tmp/configure-yadocker-cloud.groovy', 'w') as fw:
fw.write(template_output)
- template_output = jinja2_from_template('./templates', 'configure-yadocker-cloud.groovy-dryrun.j2', data)
+ template_output = jinja2_from_template(
+ './templates',
+ 'configure-yadocker-cloud.groovy-dryrun.j2', data)
publishdry = server.run_script(template_output)
logging.info(publishdry)
else: