#!/usr/bin/env python # # Workload Automation v2 for LAVA # # Copyright (C) 2014, Linaro Limited. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # Author: Milosz Wasilewski # import yaml from optparse import OptionParser TEMPLATE_PATH = "templates/" SQLITE_DB_GLOBAL_PATH = "/root/db_results/" SQLITE_DB = 'sqlite_database' CONFIG = 'config' if __name__ == '__main__': usage = "usage: %prog [OPTIONS]" parser = OptionParser(usage=usage) parser.add_option("-a", "--agenda", dest="agenda", help="Agenda file template to be used") parser.add_option("-n", "--job-name", dest="job_name", help="Job name to be used as db name in agenda file") (options, args) = parser.parse_args() if not options.agenda: parser.error("Agenda name missing") if not options.job_name: parser.error("Job name missing") agenda = open(TEMPLATE_PATH + options.agenda, "r") agenda_yaml = yaml.load(agenda) agenda_yaml[CONFIG][SQLITE_DB] = SQLITE_DB_GLOBAL_PATH + options.job_name + ".db" agenda.close() with open(options.agenda, 'w') as outfile: outfile.write( yaml.dump(agenda_yaml, default_flow_style=True) )