diff options
-rw-r--r-- | utils/agljobtemplate.py | 17 | ||||
-rwxr-xr-x | utils/create-jobs.py | 27 |
2 files changed, 24 insertions, 20 deletions
diff --git a/utils/agljobtemplate.py b/utils/agljobtemplate.py index c2e0b4a..f41dded 100644 --- a/utils/agljobtemplate.py +++ b/utils/agljobtemplate.py @@ -10,6 +10,7 @@ import urlparse def get_extension(path): return path.split('.')[-1] + def parse_url_file(template_path, url_file, url_type): url_file_path = template_path + '/URLs/' + url_file try: @@ -17,8 +18,9 @@ def parse_url_file(template_path, url_file, url_type): cfg = ConfigParser.ConfigParser() cfg.read(url_file_path) return cfg.get(url_type, 'urlbase'), cfg.get('infra', 'style') - except IOError: - raise IOError, "Unable to read from file {}".format(url_file_path) + except IOError as err: + raise err + def parse_callback_file(template_path, lava_callback, kci_callback): callback_file_path = template_path + '/callback/' + lava_callback + '.cfg' @@ -39,6 +41,7 @@ def parse_callback_file(template_path, lava_callback, kci_callback): str_err += "[releng-scripts]/templates/callback/{}.cfg".format(lava_callback) raise IOError(err, str_err) + class Agljobtemplate(object): DEFAULT_PATH = "templates" @@ -51,13 +54,13 @@ class Agljobtemplate(object): try: from jinja2 import select_autoescape except ImportError: - raise ImportError, "Please make sure your version of jinja2 is >= 2.9" + raise ImportError("Please make sure your version of jinja2 is >= 2.9") self._template_path = os.path.normpath(path) if not (os.path.isdir(self._template_path) and os.access(self._template_path, os.F_OK)): - raise OSError, "Cannot access {}".format(self._template_path) + raise OSError("Cannot access {}".format(self._template_path)) if self.machines is None: - raise RuntimeError, "No machine directory found at {}".format(self._template_path) + raise RuntimeError("No machine directory found at {}".format(self._template_path)) def __list_jinjas(self, directory): d = os.path.join(self._template_path, directory) @@ -87,13 +90,13 @@ class Agljobtemplate(object): test_templates = [] if machine not in self.machines: - raise RuntimeError, "{} is not a available machine".format(machine) + raise RuntimeError("{} is not a available machine".format(machine)) for t in tests: if t in self.tests: test_templates.append(os.path.join(self.TESTS_DIR, t + '.jinja2')) else: - raise RuntimeError, "{} is not an available test".format(t) + raise RuntimeError("{} is not an available test".format(t)) # Populate jinja substitution dict job = {} diff --git a/utils/create-jobs.py b/utils/create-jobs.py index 83ee922..e9701a5 100755 --- a/utils/create-jobs.py +++ b/utils/create-jobs.py @@ -5,11 +5,12 @@ import agljobtemplate import argparse import os + def parse_cmdline(machines, tests, rfs_types): parser = argparse.ArgumentParser(description="AGL create job", formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('-v', action='version', version='%(prog)s 1.0') - parser.add_argument('--machine', action='store', choices=machines, + parser.add_argument('--machine', action='store', choices=machines, help="machine to generate the job for", required=True) parser.add_argument('--priority', '-p', action='store', dest='priority', @@ -18,9 +19,9 @@ def parse_cmdline(machines, tests, rfs_types): parser.add_argument('--url', '-u', action='store', dest='url', help="url fetch base", default='release') - parser.add_argument('--branch', '--changeid', dest='url_branch', action='store', + parser.add_argument('--branch', '--changeid', dest='url_branch', action='store', help='The branch (or changeid) to generate the job for.') - parser.add_argument('--version', '--patchset', dest='url_version', action='store', + parser.add_argument('--version', '--patchset', dest='url_version', action='store', help='The version (or patchset) to generate the job for.') parser.add_argument('--boot', action='store', dest='rfs_type', choices=rfs_types, help='select boot type') @@ -30,21 +31,21 @@ def parse_cmdline(machines, tests, rfs_types): parser.add_argument('--callback-to', action='store', dest='callback_to', help='The KernelCI instance (name) that will receive the callback from LAVA. ' 'Please read: ./templates/callback/callback_readme.txt') - parser.add_argument('--test', dest='tests', action='store', choices=tests + ['all'], + parser.add_argument('--test', dest='tests', action='store', choices=tests + ['all'], help="add these test to the job", nargs='*', default=[]) - parser.add_argument('-o', '--output', dest='job_file', action='store', + parser.add_argument('-o', '--output', dest='job_file', action='store', help="destination file") - parser.add_argument('-n', '--name', dest='job_name', action='store', + parser.add_argument('-n', '--name', dest='job_name', action='store', help="job name", default='AGL-short-smoke-wip') - parser.add_argument('--rootfs-img', dest='rootfs_img', action='store', + parser.add_argument('--rootfs-img', dest='rootfs_img', action='store', help="The name of the root file system image (such as agl-demo-platform-raspberrypi3.ext4.xz)") - parser.add_argument('--kernel-img', dest='kernel_img', action='store', + parser.add_argument('--kernel-img', dest='kernel_img', action='store', help="The name of the kernel to boot (such as uImage)") - parser.add_argument('--dtb-img', dest='dtb_img', action='store', + parser.add_argument('--dtb-img', dest='dtb_img', action='store', help="The name of the dtb to use (such as uImage-bcm2710-rpi-3-b.dtb)") - parser.add_argument('--modules-img', dest='modules_img', action='store', + parser.add_argument('--modules-img', dest='modules_img', action='store', help="The name of the modules to use (such as modules.tar.xz)") - parser.add_argument('--build-version', dest='build_version', action='store', + parser.add_argument('--build-version', dest='build_version', action='store', help="the version number of the AGL build.") args = parser.parse_args() @@ -62,8 +63,7 @@ def parse_cmdline(machines, tests, rfs_types): parser.error("The argument '--url daily' requires '--branch' and '--version' to be set") elif (args.url == 'ci'): if (not args.url_branch) or (not args.url_version): - parser.error("The argument '--url ci' requires '--changeid' and '--patchset' to be set. " - + "For more information on how to use patchset and changeid use --help.") + parser.error("The argument '--url ci' requires '--changeid' and '--patchset' to be set.") return args @@ -99,5 +99,6 @@ def main(): else: print "Job written to: {}".format(args.job_file) + if __name__ == '__main__': main() |