diff options
author | Corentin LABBE <clabbe@baylibre.com> | 2020-06-03 15:23:53 +0200 |
---|---|---|
committer | Corentin LABBE <clabbe@baylibre.com> | 2020-06-11 08:04:46 +0200 |
commit | b5bcfa146da2baf76fd466a7130a08465e9331ba (patch) | |
tree | 2d57826a0c1c1fb985e5af2fbc727a699e5f8faa /utils/agljobtemplate.py | |
parent | b7b65449c824bc5cd7fdd0fba4a190fb47090e68 (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>
Diffstat (limited to 'utils/agljobtemplate.py')
-rw-r--r-- | utils/agljobtemplate.py | 17 |
1 files changed, 9 insertions, 8 deletions
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 = '' |