pull/32007/head
Cheng-Yu Chung 2 years ago
parent 3c9b4f0926
commit 5522d226c4
  1. 2
      src/abseil-cpp/gen_build_yaml.py
  2. 2
      src/abseil-cpp/preprocessed_builds.yaml.gen.py
  3. 2
      src/benchmark/gen_build_yaml.py
  4. 6
      src/boringssl/gen_build_yaml.py
  5. 2
      src/c-ares/gen_build_yaml.py
  6. 2
      src/proto/gen_build_yaml.py
  7. 2
      src/re2/gen_build_yaml.py
  8. 2
      src/upb/gen_build_yaml.py
  9. 2
      src/zlib/gen_build_yaml.py
  10. 2
      test/core/end2end/gen_build_yaml.py
  11. 2
      test/cpp/naming/gen_build_yaml.py
  12. 2
      test/cpp/naming/utils/run_dns_server_for_lb_interop_tests.py
  13. 2
      tools/buildgen/build_cleaner.py
  14. 5
      tools/buildgen/generate_projects.py
  15. 4
      tools/buildgen/plugins/list_api.py
  16. 2
      tools/run_tests/lb_interop_tests/gen_build_yaml.py
  17. 17
      tools/run_tests/performance/loadtest_config.py
  18. 13
      tools/run_tests/performance/loadtest_template.py
  19. 2
      tools/run_tests/python_utils/port_server.py
  20. 9
      tools/run_tests/xds_k8s_test_driver/framework/infrastructure/gcp/api.py
  21. 3
      tools/run_tests/xds_k8s_test_driver/framework/infrastructure/k8s.py

@ -27,4 +27,4 @@ for build in builds:
build['build_system'] = []
build['language'] = 'c'
build['secure'] = False
print(yaml.dump({'libs': builds}))
print(yaml.safe_dump({'libs': builds}))

@ -206,7 +206,7 @@ def main():
builds = generate_builds("absl")
os.chdir(previous_dir)
with open(OUTPUT_PATH, 'w') as outfile:
outfile.write(yaml.dump(builds, indent=2))
outfile.write(yaml.safe_dump(builds, indent=2))
if __name__ == "__main__":

@ -42,4 +42,4 @@ out['libs'] = [{
glob.glob('third_party/benchmark/include/benchmark/*.h')),
}]
print(yaml.dump(out))
print(yaml.safe_dump(out))

@ -71,8 +71,8 @@ class Grpc(object):
map_dir(f) for f in files['ssl'] + files['crypto']),
'asm_src': {
k: [map_dir(f) for f in value
] for k, value in asm_outputs.items()
},
] for k, value in asm_outputs.items()
},
'headers':
sorted(
map_dir(f)
@ -130,4 +130,4 @@ class Grpc(object):
grpc_platform = Grpc(sources)
print(yaml.dump(grpc_platform.yaml))
print(yaml.safe_dump(grpc_platform.yaml))

@ -154,4 +154,4 @@ try:
except:
pass
print(yaml.dump(out))
print(yaml.safe_dump(out))

@ -76,7 +76,7 @@ def main():
'proto_transitive_external_deps': deps_external_trans
}
print(yaml.dump(json))
print(yaml.safe_dump(json))
if __name__ == '__main__':

@ -45,4 +45,4 @@ out['libs'] = [{
glob.glob('third_party/re2/util/*.h')),
}]
print(yaml.dump(out))
print(yaml.safe_dump(out))

@ -92,4 +92,4 @@ try:
except:
pass
print(yaml.dump(out))
print(yaml.safe_dump(out))

@ -58,4 +58,4 @@ try:
except:
pass
print(yaml.dump(out))
print(yaml.safe_dump(out))

@ -46,7 +46,7 @@ def main():
'core_end2end_tests':
dict((t, END2END_TESTS[t]['secure']) for t in END2END_TESTS.keys())
}
print(yaml.dump(json))
print(yaml.safe_dump(json))
if __name__ == '__main__':

@ -76,7 +76,7 @@ def main():
_resolver_test_cases(resolver_component_data),
}
print(yaml.dump(json))
print(yaml.safe_dump(json))
if __name__ == '__main__':

@ -97,7 +97,7 @@ if args.cause_no_error_no_data_for_balancer_a_record:
# Generate the actual DNS server records config file
records_config_path = tempfile.mktemp()
with open(records_config_path, 'w') as records_config_generated:
records_config_generated.write(yaml.dump(records_config_yaml))
records_config_generated.write(yaml.safe_dump(records_config_yaml))
with open(records_config_path, 'r') as records_config_generated:
sys.stderr.write('===== DNS server records config: =====\n')

@ -76,7 +76,7 @@ def cleaned_build_yaml_dict_as_string(indict):
continue
js[grp] = sorted([_clean_elem(x) for x in js[grp]],
key=lambda x: (x.get('language', '_'), x['name']))
output = yaml.dump(js, indent=2, width=80, default_flow_style=False)
output = yaml.safe_dump(js, indent=2, width=80, default_flow_style=False)
# massage out trailing whitespace
lines = []
for line in output.splitlines():

@ -71,15 +71,14 @@ def preprocess_build_files() -> _utils.Bunch:
build_spec = dict()
for build_file in args.build_files:
with open(build_file, 'r') as f:
_utils.merge_json(build_spec,
yaml.safe_load(f.read()))
_utils.merge_json(build_spec, yaml.safe_load(f.read()))
# Executes plugins. Plugins update the build spec in-place.
for py_file in sorted(glob.glob('tools/buildgen/plugins/*.py')):
plugin = _utils.import_python_module(py_file)
plugin.mako_plugin(build_spec)
if args.output_merged:
with open(args.output_merged, 'w') as f:
f.write(yaml.dump(build_spec))
f.write(yaml.safe_dump(build_spec))
# Makes build_spec sort of immutable and dot-accessible
return _utils.to_bunch(build_spec)

@ -66,5 +66,5 @@ def mako_plugin(dictionary):
if __name__ == '__main__':
print(
(yaml.dump([api for api in list_c_apis(headers_under('include/grpc'))
])))
(yaml.safe_dump([api for api in list_c_apis(headers_under('include/grpc'))
])))

@ -341,6 +341,6 @@ def generate_client_referred_to_backend_multiple_balancers():
all_scenarios += generate_client_referred_to_backend_multiple_balancers()
print((yaml.dump({
print((yaml.safe_dump({
'lb_interop_test_scenarios': all_scenarios,
})))

@ -21,6 +21,8 @@
# See documentation below:
# https://github.com/grpc/grpc/blob/master/tools/run_tests/performance/README.md#grpc-oss-benchmarks
import scenario_config_exporter
import scenario_config
import argparse
import collections
import copy
@ -35,8 +37,6 @@ from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Type
import yaml
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
import scenario_config
import scenario_config_exporter
CONFIGURATION_FILE_HEADER_COMMENT = """
# Load test configurations generated from a template by loadtest_config.py.
@ -223,7 +223,8 @@ def gen_loadtest_configs(
metadata['name'] = name
if 'labels' not in metadata:
metadata['labels'] = dict()
metadata['labels']['language'] = safe_name(language_config.language)
metadata['labels']['language'] = safe_name(
language_config.language)
metadata['labels']['prefix'] = prefix
if 'annotations' not in metadata:
metadata['annotations'] = dict()
@ -522,11 +523,11 @@ def main() -> None:
configs = (config for config in itertools.chain(*config_generators))
with open(args.output, 'w') if args.output else sys.stdout as f:
yaml.dump_all(configs,
stream=f,
Dumper=config_dumper(
CONFIGURATION_FILE_HEADER_COMMENT.strip()),
default_flow_style=False)
yaml.safe_dump_all(configs,
stream=f,
Dumper=config_dumper(
CONFIGURATION_FILE_HEADER_COMMENT.strip()),
default_flow_style=False)
if __name__ == '__main__':

@ -25,6 +25,7 @@
# below:
# https://github.com/grpc/grpc/blob/master/tools/run_tests/performance/README.md
import loadtest_config
import argparse
import os
import sys
@ -33,7 +34,6 @@ from typing import Any, Dict, Iterable, List, Mapping, Type
import yaml
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
import loadtest_config
TEMPLATE_FILE_HEADER_COMMENT = """
# Template generated from load test configurations by loadtest_template.py.
@ -54,7 +54,7 @@ def insert_worker(worker: Dict[str, Any], workers: List[Dict[str,
"""Inserts client or server into a list, without inserting duplicates."""
def dump(w):
return yaml.dump(w, Dumper=yaml.SafeDumper, default_flow_style=False)
return yaml.safe_dump(w, default_flow_style=False)
worker_str = dump(worker)
if any((worker_str == dump(w) for w in workers)):
@ -261,10 +261,11 @@ def main() -> None:
inject_ttl_seconds=args.inject_ttl_seconds)
with open(args.output, 'w') if args.output else sys.stdout as f:
yaml.dump(template,
stream=f,
Dumper=template_dumper(TEMPLATE_FILE_HEADER_COMMENT.strip()),
default_flow_style=False)
yaml.safe_dump(template,
stream=f,
Dumper=template_dumper(
TEMPLATE_FILE_HEADER_COMMENT.strip()),
default_flow_style=False)
if __name__ == '__main__':

@ -191,7 +191,7 @@ class Handler(BaseHTTPRequestHandler):
self.end_headers()
mu.acquire()
now = time.time()
out = yaml.dump({
out = yaml.safe_dump({
'pool': pool,
'in_use': dict((k, now - v) for k, v in list(in_use.items()))
})

@ -194,7 +194,8 @@ class GcpApiManager:
params_str = ''
if params:
params_str = '&' + ('&'.join(f'{k}={v}' for k, v in params.items()))
params_str = '&' + \
('&'.join(f'{k}={v}' for k, v in params.items()))
api = discovery.build(
api_name,
@ -364,7 +365,8 @@ class GcpProjectApiResource:
def resource_pretty_format(self, body: dict) -> str:
"""Return a string with pretty-printed resource body."""
yaml_out: str = yaml.dump(body, explicit_start=True, explicit_end=True)
yaml_out: str = yaml.safe_dump(
body, explicit_start=True, explicit_end=True)
return self._highlighter.highlight(yaml_out)
@staticmethod
@ -426,7 +428,8 @@ class GcpStandardCloudApiResource(GcpProjectApiResource, metaclass=abc.ABCMeta):
return True
except _HttpError as error:
if error.resp and error.resp.status == 404:
logger.info('%s not deleted since it does not exist', full_name)
logger.info(
'%s not deleted since it does not exist', full_name)
else:
logger.warning('Failed to delete %s, %r', full_name, error)
return False

@ -365,7 +365,8 @@ class KubernetesNamespace: # pylint: disable=too-many-public-methods
def _pretty_format(self, data: dict) -> str:
"""Return a string with pretty-printed yaml data from a python dict."""
yaml_out: str = yaml.dump(data, explicit_start=True, explicit_end=True)
yaml_out: str = yaml.safe_dump(
data, explicit_start=True, explicit_end=True)
return self._highlighter.highlight(yaml_out)
@classmethod

Loading…
Cancel
Save