diff options
author | Christian Breunig <christian@breunig.cc> | 2024-03-12 23:30:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-12 23:30:52 +0100 |
commit | 2ef1bded20c26dd759b696fa47897e4cc3132450 (patch) | |
tree | a46335f1af7601cc2347fb1f45f59d7fdc744d7c /scripts | |
parent | b6a56286c3816024bc128c9f55fcd2ce1d9e77ce (diff) | |
parent | bbddf9d0a32e60717871dfe665cc4d443117dcfe (diff) | |
download | vyos-build-2ef1bded20c26dd759b696fa47897e4cc3132450.tar.gz vyos-build-2ef1bded20c26dd759b696fa47897e4cc3132450.zip |
Merge pull request #527 from dmbaturin/T6119-tomli-current
docker, build: T6119: use python3-tomli instead of python3-toml for a compliant implementation ot TOML
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/build-vyos-image | 20 | ||||
-rwxr-xr-x | scripts/check-qemu-install | 6 |
2 files changed, 13 insertions, 13 deletions
diff --git a/scripts/build-vyos-image b/scripts/build-vyos-image index 8b91de57..95ce3125 100755 --- a/scripts/build-vyos-image +++ b/scripts/build-vyos-image @@ -32,12 +32,12 @@ import functools import json try: - import toml + import tomli import jinja2 import git except ModuleNotFoundError as e: print(f"Cannot load a required library: {e}") - print("Please make sure the following Python3 modules are installed: toml jinja2 git") + print("Please make sure the following Python3 modules are installed: tomli jinja2 git") import vyos_build_utils as utils import vyos_build_defaults as defaults @@ -120,8 +120,8 @@ if __name__ == "__main__": ## Load the file with default build configuration options try: - with open(defaults.DEFAULTS_FILE, 'r') as f: - build_defaults = toml.load(f) + with open(defaults.DEFAULTS_FILE, 'rb') as f: + build_defaults = tomli.load(f) except Exception as e: print("Failed to open the defaults file {0}: {1}".format(defaults.DEFAULTS_FILE, e)) sys.exit(1) @@ -193,8 +193,8 @@ if __name__ == "__main__": pre_build_config = merge_dicts({}, build_defaults) flavor_config = {} - with open(make_toml_path(defaults.BUILD_FLAVORS_DIR, args["build_flavor"]), 'r') as f: - flavor_config = toml.load(f) + with open(make_toml_path(defaults.BUILD_FLAVORS_DIR, args["build_flavor"]), 'rb') as f: + flavor_config = tomli.load(f) pre_build_config = merge_dicts(flavor_config, pre_build_config) ## Combine configs args > flavor > defaults @@ -226,12 +226,12 @@ if __name__ == "__main__": build_config = merge_dicts({}, build_defaults) ## Load correct mix-ins - with open(make_toml_path(defaults.BUILD_TYPES_DIR, pre_build_config["build_type"]), 'r') as f: - build_type_config = toml.load(f) + with open(make_toml_path(defaults.BUILD_TYPES_DIR, pre_build_config["build_type"]), 'rb') as f: + build_type_config = tomli.load(f) build_config = merge_dicts(build_type_config, build_config) - with open(make_toml_path(defaults.BUILD_ARCHES_DIR, pre_build_config["architecture"]), 'r') as f: - build_arch_config = toml.load(f) + with open(make_toml_path(defaults.BUILD_ARCHES_DIR, pre_build_config["architecture"]), 'rb') as f: + build_arch_config = tomli.load(f) build_config = merge_dicts(build_arch_config, build_config) ## Override with flavor and then CLI arguments diff --git a/scripts/check-qemu-install b/scripts/check-qemu-install index b77e5023..41c566e6 100755 --- a/scripts/check-qemu-install +++ b/scripts/check-qemu-install @@ -42,7 +42,7 @@ import random import traceback import logging import re -import toml +import tomli from io import BytesIO from io import StringIO @@ -82,8 +82,8 @@ parser.add_argument('--qemu-cmd', help='Only generate QEMU launch command', args = parser.parse_args() -with open('data/defaults.toml') as f: - vyos_defaults = toml.load(f) +with open('data/defaults.toml', 'rb') as f: + vyos_defaults = tomli.load(f) class StreamToLogger(object): """ |