From 790059069915a700905f4746b22a9a4a6cadc6ad Mon Sep 17 00:00:00 2001 From: Yaroslav Brustinov Date: Thu, 2 Feb 2017 09:33:02 +0200 Subject: replace yaml.load with yaml.safe_load in several places Change-Id: I4ba8291acbb56ed3be58ad9bdfa1492892695458 Signed-off-by: Yaroslav Brustinov --- .../automation/trex_control_plane/client_utils/yaml_utils.py | 2 +- scripts/automation/trex_control_plane/doc/docs_utilities.py | 12 ++++++------ .../trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'scripts/automation/trex_control_plane') diff --git a/scripts/automation/trex_control_plane/client_utils/yaml_utils.py b/scripts/automation/trex_control_plane/client_utils/yaml_utils.py index 776a51a7..20a2c587 100644 --- a/scripts/automation/trex_control_plane/client_utils/yaml_utils.py +++ b/scripts/automation/trex_control_plane/client_utils/yaml_utils.py @@ -150,7 +150,7 @@ class CTRexYAMLLoader(object): def load_yaml_to_obj(file_path): try: - return yaml.load(file(file_path, 'r')) + return yaml.safe_load(file(file_path, 'r')) except yaml.YAMLError as e: raise except Exception as e: diff --git a/scripts/automation/trex_control_plane/doc/docs_utilities.py b/scripts/automation/trex_control_plane/doc/docs_utilities.py index e80d765f..7c65be6e 100755 --- a/scripts/automation/trex_control_plane/doc/docs_utilities.py +++ b/scripts/automation/trex_control_plane/doc/docs_utilities.py @@ -11,13 +11,13 @@ def handle_data_items(field_yaml_dict): def json_dict_to_txt_table(dict_yaml_file): - + # table = Texttable(max_width=120) with open(dict_yaml_file, 'r') as f: - yaml_stream = yaml.load(f) + yaml_stream = yaml.safe_load(f) for main_field, sub_key in yaml_stream.items(): - print main_field + ' field' '\n' + '~'*len(main_field+' field') + '\n' + print(main_field + ' field' '\n' + '~'*len(main_field+' field') + '\n') field_data_rows = handle_data_items(sub_key) table = Texttable(max_width=120) @@ -28,10 +28,10 @@ def json_dict_to_txt_table(dict_yaml_file): table.add_rows(field_data_rows, header=False) - print table.draw() + "\n" + print(table.draw() + "\n") + + - - json_dict_to_txt_table("json_dictionary.yaml") \ No newline at end of file diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py index 26613e56..efa450e1 100755 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py @@ -821,7 +821,7 @@ class YAMLLoader(object): yaml_str = f.read() try: - objects = yaml.load(yaml_str) + objects = yaml.safe_load(yaml_str) except yaml.parser.ParserError as e: raise STLError(str(e)) -- cgit 1.2.3-korg