aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorentin LABBE <clabbe@baylibre.com>2020-06-03 15:23:53 +0200
committerCorentin LABBE <clabbe@baylibre.com>2020-06-11 08:04:46 +0200
commitb5bcfa146da2baf76fd466a7130a08465e9331ba (patch)
tree2d57826a0c1c1fb985e5af2fbc727a699e5f8faa
parentb7b65449c824bc5cd7fdd0fba4a190fb47090e68 (diff)
SPEC-3408: convert releng-scripts to python3
This patch convert releng-scripts to python3. While at it, let's creating requirements.txt for specifying depencies yaml and jinja2. Change-Id: Iba7b45b10fd7e1336bf1e4a73e0e6275392e373c Bug-AGL: SPEC-3408 Signed-off-by: Corentin LABBE <clabbe@baylibre.com>
-rw-r--r--requirements.txt2
-rw-r--r--utils/agljobtemplate.py17
-rwxr-xr-xutils/create-jobs.py8
-rwxr-xr-xutils/job-prereq.py8
4 files changed, 19 insertions, 16 deletions
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..454abc7
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,2 @@
+yaml
+jinja2
diff --git a/utils/agljobtemplate.py b/utils/agljobtemplate.py
index c9d07f5..639492c 100644
--- a/utils/agljobtemplate.py
+++ b/utils/agljobtemplate.py
@@ -1,10 +1,11 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import jinja2
-import ConfigParser
-import urlparse
+import configparser
+from urllib.parse import urlparse
+from urllib.parse import urljoin
import ast
@@ -16,7 +17,7 @@ def parse_cfg_file(template_path, cfg_file, build_type):
url_file_path = template_path + '/config/' + cfg_file
try:
with open(url_file_path):
- cfg = ConfigParser.ConfigParser()
+ cfg = configparser.ConfigParser()
cfg.read(url_file_path)
return cfg.items(build_type), cfg.get('infra', 'style')
except IOError as err:
@@ -27,7 +28,7 @@ def parse_callback_file(template_path, lava_callback, kci_callback):
callback_file_path = template_path + '/callback/' + lava_callback + '.cfg'
try:
with open(callback_file_path):
- cfg = ConfigParser.ConfigParser()
+ cfg = configparser.ConfigParser()
cfg.read(callback_file_path)
if kci_callback is None:
kci_callback = cfg.get('default', 'section')
@@ -36,10 +37,10 @@ def parse_callback_file(template_path, lava_callback, kci_callback):
for callback_target in kci_callback:
cb_data.append(dict(cfg.items(callback_target)))
return cb_data
- except (ConfigParser.NoSectionError) as err:
+ except (configparser.NoSectionError) as err:
str_err = "'--callback-to {}': must correspond to a section [{}] in the file '{}.cfg'".format(
kci_callback, kci_callback, lava_callback)
- raise ConfigParser.NoSectionError(str_err)
+ raise configparser.NoSectionError(str_err)
except (IOError) as err:
str_err = "\n'--callback-from {}': must correspond to a file located in: ".format(lava_callback)
str_err += "[releng-scripts]/templates/callback/{}.cfg".format(lava_callback)
@@ -149,7 +150,7 @@ class Agljobtemplate(object):
if (build_type != 'ci'):
url_fragment += '/deploy/images/' + machine_frag_url
- url = urlparse.urljoin(url_base, url_fragment)
+ url = urljoin(url_base, url_fragment)
if applications_url is None:
app_url_base = ''
diff --git a/utils/create-jobs.py b/utils/create-jobs.py
index b2a7363..f3a158f 100755
--- a/utils/create-jobs.py
+++ b/utils/create-jobs.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import agljobtemplate
@@ -110,16 +110,16 @@ def main():
app_changeid=args.app_changeid, app_patchset=args.app_patchset, app_branch=args.app_branch)
if args.job_file is None:
- print job
+ print(job)
else:
try:
with open(args.job_file, 'w') as j:
j.write(job)
except IOError as e:
- print "{}: {}".format(e.strerror, args.job_file)
+ print("{}: {}".format(e.strerror, args.job_file))
exit(e.errno)
else:
- print "Job written to: {}".format(args.job_file)
+ print("Job written to: {}".format(args.job_file))
if __name__ == '__main__':
diff --git a/utils/job-prereq.py b/utils/job-prereq.py
index 08531cd..213a84a 100755
--- a/utils/job-prereq.py
+++ b/utils/job-prereq.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import agljobtemplate
@@ -67,15 +67,15 @@ def main():
if args.machine == "qemux86-64" or args.machine == "qemuarm" or args.machine == "qemuarm64":
for key in FILE_MAP_QEMU:
if getattr(args, key):
- print job_yaml["actions"][0]["deploy"]["images"][FILE_MAP_QEMU[key]].get("url").split('/')[-1]
+ print(job_yaml["actions"][0]["deploy"]["images"][FILE_MAP_QEMU[key]].get("url").split('/')[-1])
elif args.machine == "intel-corei7-64" or args.machine == "upsquare":
for key in FILE_MAP_X86:
if getattr(args, key):
- print job_yaml["actions"][0]["deploy"][key].get("url").split('/')[-1]
+ print(job_yaml["actions"][0]["deploy"][key].get("url").split('/')[-1])
else:
for key in FILE_MAP:
if getattr(args, key):
- print job_yaml["actions"][0]["deploy"][key].get("url").split('/')[-1]
+ print(job_yaml["actions"][0]["deploy"][key].get("url").split('/')[-1])
if __name__ == '__main__':
main()