replace yaml.load with yaml.safe_load in several places 74/5374/1
authorYaroslav Brustinov <[email protected]>
Thu, 2 Feb 2017 07:33:02 +0000 (09:33 +0200)
committerYaroslav Brustinov <[email protected]>
Thu, 2 Feb 2017 07:33:02 +0000 (09:33 +0200)
Change-Id: I4ba8291acbb56ed3be58ad9bdfa1492892695458
Signed-off-by: Yaroslav Brustinov <[email protected]>
scripts/automation/regression/misc_methods.py
scripts/automation/trex_control_plane/client_utils/yaml_utils.py
scripts/automation/trex_control_plane/doc/docs_utilities.py
scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_streams.py

index 99071f8..d879b03 100755 (executable)
@@ -128,7 +128,7 @@ def load_complete_config_file (filepath):
 
     try:
         with open(filepath, 'r') as f:
-            config = yaml.load(f)
+            config = yaml.safe_load(f)
             
             # Handle TRex configuration
             trex_config['trex_name']         = config["trex"]["hostname"]
@@ -176,7 +176,7 @@ def load_complete_config_file (filepath):
 def load_object_config_file (filepath):
     try:
         with open(filepath, 'r') as f:
-            config = yaml.load(f)
+            config = yaml.safe_load(f)
             return config
     except Exception as inst:
         print("\nBad configuration file provided: '{0}'\n".format(filepath))
@@ -229,7 +229,7 @@ def load_benchmark_config_file (filepath):
 
     try:
         with open(filepath, 'r') as f:
-            benchmark_config = yaml.load(f)
+            benchmark_config = yaml.safe_load(f)
 
     except Exception as inst:
         print("\nBad configuration file provided: '{0}'\n".format(filepath))
index 776a51a..20a2c58 100644 (file)
@@ -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:
index e80d765..7c65be6 100755 (executable)
@@ -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
index 26613e5..efa450e 100755 (executable)
@@ -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))