diff options
author | Trevor Bramwell <tbramwell@linuxfoundation.org> | 2018-03-16 14:14:12 -0700 |
---|---|---|
committer | Trevor Bramwell <tbramwell@linuxfoundation.org> | 2018-03-19 15:50:25 -0700 |
commit | 434509e22a2ce3578e226bcaa68d4d2b4ceece2b (patch) | |
tree | 9f916a892ccf50310b31e110f43952565a710036 /jjb/apex | |
parent | 07a4bcdbebbc4165a67e3fb0f4b0d078928268a2 (diff) |
Make Apex JJB Renderer Importable
Wrapping the script into a function will make it importable from other
python code. Calling the file directly will still work as it did before.
Change-Id: I8336d34b05687fa650ce1c123bb37fa311ce2978
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
Diffstat (limited to 'jjb/apex')
-rw-r--r-- | jjb/apex/apex-jjb-renderer.py | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/jjb/apex/apex-jjb-renderer.py b/jjb/apex/apex-jjb-renderer.py index 6fd83afe9..b67784376 100644 --- a/jjb/apex/apex-jjb-renderer.py +++ b/jjb/apex/apex-jjb-renderer.py @@ -12,30 +12,38 @@ import yaml from jinja2 import Environment from jinja2 import FileSystemLoader -gspathname = dict() -branch = dict() -build_slave = dict() -env = Environment(loader=FileSystemLoader('./'), autoescape=True) -with open('scenarios.yaml.hidden') as _: - scenarios = yaml.safe_load(_) +def render_jjb(): + """Render JJB output from scenarios.yaml.hidden file and jinja + template""" -template = env.get_template('apex.yml.j2') + gspathname = dict() + branch = dict() + build_slave = dict() + env = Environment(loader=FileSystemLoader('./'), autoescape=True) -print("Scenarios are: ") -pprint.pprint(scenarios) + with open('scenarios.yaml.hidden') as _: + scenarios = yaml.safe_load(_) -for stream in scenarios: - if stream == 'master': - gspathname['master'] = '' - branch[stream] = stream - else: - gspathname[stream] = '/' + stream - branch[stream] = 'stable/' + stream - build_slave[stream] = 'apex-baremetal-{}'.format(stream) + template = env.get_template('apex.yml.j2') -output = template.render(scenarios=scenarios, gspathname=gspathname, - branch=branch, build_slave=build_slave) + print("Scenarios are: ") + pprint.pprint(scenarios) -with open('./apex.yml', 'w') as fh: - fh.write(output) + for stream in scenarios: + if stream == 'master': + gspathname['master'] = '' + branch[stream] = stream + else: + gspathname[stream] = '/' + stream + branch[stream] = 'stable/' + stream + build_slave[stream] = 'apex-baremetal-{}'.format(stream) + + output = template.render(scenarios=scenarios, gspathname=gspathname, + branch=branch, build_slave=build_slave) + + with open('./apex.yml', 'w') as fh: + fh.write(output) + +if __name__ == "__main__": + render_jjb() |