kopia lustrzana https://github.com/espressif/esp-idf
python: Fix yaml.load warnings
Since pyyaml 5.1 yaml.load without specifing loader is deprecated Details: https://msg.pyyaml.org/load To keep code compatible with older versions of pyyaml and keep best perfomance CLoader with fallback to Loader is used.pull/4082/head
rodzic
c27fd32fbe
commit
c57dfbc0b8
|
@ -7,6 +7,11 @@ import os
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
try:
|
||||||
|
from yaml import CLoader as Loader
|
||||||
|
except ImportError:
|
||||||
|
from yaml import Loader as Loader
|
||||||
|
|
||||||
IDF_PATH = os.getenv("IDF_PATH")
|
IDF_PATH = os.getenv("IDF_PATH")
|
||||||
if not IDF_PATH:
|
if not IDF_PATH:
|
||||||
print("Please set IDF_PATH before running this script")
|
print("Please set IDF_PATH before running this script")
|
||||||
|
@ -17,7 +22,7 @@ GITLAB_CONFIG_FILE = os.path.join(os.getenv("IDF_PATH"), ".gitlab-ci.yml")
|
||||||
|
|
||||||
def check_artifacts_expire_time():
|
def check_artifacts_expire_time():
|
||||||
with open(GITLAB_CONFIG_FILE, "r") as f:
|
with open(GITLAB_CONFIG_FILE, "r") as f:
|
||||||
config = yaml.load(f)
|
config = yaml.load(f, Loader=Loader)
|
||||||
|
|
||||||
errors = []
|
errors = []
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,11 @@ import argparse
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
try:
|
||||||
|
from yaml import CLoader as Loader
|
||||||
|
except ImportError:
|
||||||
|
from yaml import Loader as Loader
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from Utility import CIAssignTest
|
from Utility import CIAssignTest
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -110,7 +115,7 @@ class UnitTestAssignTest(CIAssignTest.AssignTest):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(test_case_path, "r") as f:
|
with open(test_case_path, "r") as f:
|
||||||
raw_data = yaml.load(f)
|
raw_data = yaml.load(f, Loader=Loader)
|
||||||
test_cases = raw_data["test cases"]
|
test_cases = raw_data["test cases"]
|
||||||
except IOError:
|
except IOError:
|
||||||
print("Test case path is invalid. Should only happen when use @bot to skip unit test.")
|
print("Test case path is invalid. Should only happen when use @bot to skip unit test.")
|
||||||
|
|
|
@ -34,6 +34,11 @@ This will prevent test cases from getting configs from other env when there're c
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
try:
|
||||||
|
from yaml import CLoader as Loader
|
||||||
|
except ImportError:
|
||||||
|
from yaml import Loader as Loader
|
||||||
|
|
||||||
|
|
||||||
class Config(object):
|
class Config(object):
|
||||||
""" Test Env Config """
|
""" Test Env Config """
|
||||||
|
@ -52,7 +57,7 @@ class Config(object):
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
with open(config_file) as f:
|
with open(config_file) as f:
|
||||||
configs = yaml.load(f)[env_name]
|
configs = yaml.load(f, Loader=Loader)[env_name]
|
||||||
except (OSError, TypeError, IOError):
|
except (OSError, TypeError, IOError):
|
||||||
configs = dict()
|
configs = dict()
|
||||||
return configs
|
return configs
|
||||||
|
|
|
@ -14,6 +14,11 @@
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
try:
|
||||||
|
from yaml import CLoader as Loader
|
||||||
|
except ImportError:
|
||||||
|
from yaml import Loader as Loader
|
||||||
|
|
||||||
|
|
||||||
class TestCase(object):
|
class TestCase(object):
|
||||||
"""
|
"""
|
||||||
|
@ -45,7 +50,7 @@ class TestCase(object):
|
||||||
"""
|
"""
|
||||||
doc_string = self.test_method.__doc__
|
doc_string = self.test_method.__doc__
|
||||||
try:
|
try:
|
||||||
doc = yaml.load(doc_string)
|
doc = yaml.load(doc_string, Loader=Loader)
|
||||||
except (AttributeError, OSError, UnicodeDecodeError):
|
except (AttributeError, OSError, UnicodeDecodeError):
|
||||||
doc = self.DEFAULT_CASE_DOC
|
doc = self.DEFAULT_CASE_DOC
|
||||||
doc.update(self.test_method.env_args)
|
doc.update(self.test_method.env_args)
|
||||||
|
|
|
@ -47,6 +47,11 @@ import yaml
|
||||||
|
|
||||||
from Utility import (CaseConfig, SearchCases, GitlabCIJob, console_log)
|
from Utility import (CaseConfig, SearchCases, GitlabCIJob, console_log)
|
||||||
|
|
||||||
|
try:
|
||||||
|
from yaml import CLoader as Loader
|
||||||
|
except ImportError:
|
||||||
|
from yaml import Loader as Loader
|
||||||
|
|
||||||
|
|
||||||
class Group(object):
|
class Group(object):
|
||||||
|
|
||||||
|
@ -150,7 +155,7 @@ class AssignTest(object):
|
||||||
def _parse_gitlab_ci_config(self, ci_config_file):
|
def _parse_gitlab_ci_config(self, ci_config_file):
|
||||||
|
|
||||||
with open(ci_config_file, "r") as f:
|
with open(ci_config_file, "r") as f:
|
||||||
ci_config = yaml.load(f)
|
ci_config = yaml.load(f, Loader=Loader)
|
||||||
|
|
||||||
job_list = list()
|
job_list = list()
|
||||||
for job_name in ci_config:
|
for job_name in ci_config:
|
||||||
|
|
|
@ -49,6 +49,11 @@ import TestCase
|
||||||
|
|
||||||
from Utility import load_source
|
from Utility import load_source
|
||||||
|
|
||||||
|
try:
|
||||||
|
from yaml import CLoader as Loader
|
||||||
|
except ImportError:
|
||||||
|
from yaml import Loader as Loader
|
||||||
|
|
||||||
|
|
||||||
def _convert_to_lower_case_bytes(item):
|
def _convert_to_lower_case_bytes(item):
|
||||||
"""
|
"""
|
||||||
|
@ -154,7 +159,7 @@ class Parser(object):
|
||||||
configs = cls.DEFAULT_CONFIG.copy()
|
configs = cls.DEFAULT_CONFIG.copy()
|
||||||
if config_file:
|
if config_file:
|
||||||
with open(config_file, "r") as f:
|
with open(config_file, "r") as f:
|
||||||
configs.update(yaml.load(f))
|
configs.update(yaml.load(f), Loader=Loader)
|
||||||
return configs
|
return configs
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
@ -8,6 +8,11 @@ import subprocess
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
import CreateSectionTable
|
import CreateSectionTable
|
||||||
|
|
||||||
|
try:
|
||||||
|
from yaml import CLoader as Loader
|
||||||
|
except ImportError:
|
||||||
|
from yaml import Loader as Loader
|
||||||
|
|
||||||
TEST_CASE_PATTERN = {
|
TEST_CASE_PATTERN = {
|
||||||
"initial condition": "UTINIT1",
|
"initial condition": "UTINIT1",
|
||||||
"SDK": "ESP32_IDF",
|
"SDK": "ESP32_IDF",
|
||||||
|
@ -50,9 +55,10 @@ class Parser(object):
|
||||||
self.unit_jobs = {}
|
self.unit_jobs = {}
|
||||||
self.file_name_cache = {}
|
self.file_name_cache = {}
|
||||||
self.idf_path = idf_path
|
self.idf_path = idf_path
|
||||||
self.tag_def = yaml.load(open(os.path.join(idf_path, self.TAG_DEF_FILE), "r"))
|
self.tag_def = yaml.load(open(os.path.join(idf_path, self.TAG_DEF_FILE), "r"), Loader=Loader)
|
||||||
self.module_map = yaml.load(open(os.path.join(idf_path, self.MODULE_DEF_FILE), "r"))
|
self.module_map = yaml.load(open(os.path.join(idf_path, self.MODULE_DEF_FILE), "r"), Loader=Loader)
|
||||||
self.config_dependencies = yaml.load(open(os.path.join(idf_path, self.CONFIG_DEPENDENCY_FILE), "r"))
|
self.config_dependencies = yaml.load(open(os.path.join(idf_path, self.CONFIG_DEPENDENCY_FILE), "r"),
|
||||||
|
Loader=Loader)
|
||||||
# used to check if duplicated test case names
|
# used to check if duplicated test case names
|
||||||
self.test_case_names = set()
|
self.test_case_names = set()
|
||||||
self.parsing_errors = []
|
self.parsing_errors = []
|
||||||
|
|
Ładowanie…
Reference in New Issue