|
@@ -19,10 +19,53 @@ osgb = 'thq_20230710.osgb'
|
|
|
|
|
|
vehicle_name = 'PuJin_distribution'
|
|
|
xoscName = 'scenario.xosc'
|
|
|
-logging.basicConfig(filename=path2 + 'log/2simulation.log', level=logging.INFO,
|
|
|
+logging.basicConfig(filename=path2 + 'log/2simulation-pjibot_delivery.log', level=logging.INFO,
|
|
|
format='%(asctime)s - %(levelname)s - %(message)s')
|
|
|
|
|
|
-sleep_time = 60
|
|
|
+sleep_time = 30
|
|
|
+
|
|
|
+error_bag_json = "/mnt/disk001/dcl_data_process/src/python2/pjisuv/2simulation-errorBag.json"
|
|
|
+
|
|
|
+
|
|
|
+def parse_json_to_string_array(file_path):
|
|
|
+ try:
|
|
|
+
|
|
|
+ with open(file_path, 'r') as file:
|
|
|
+
|
|
|
+ file_content = file.read()
|
|
|
+
|
|
|
+ data = json.loads(file_content.decode('utf-8'))
|
|
|
+
|
|
|
+
|
|
|
+ if isinstance(data, list):
|
|
|
+ for item in data:
|
|
|
+ if not isinstance(item, basestring):
|
|
|
+ raise ValueError("JSON数组中的元素不是字符串")
|
|
|
+ return data
|
|
|
+ else:
|
|
|
+ return []
|
|
|
+ except Exception as e:
|
|
|
+ return []
|
|
|
+
|
|
|
+
|
|
|
+def list_to_json_file(data, file_path):
|
|
|
+ """
|
|
|
+ 将列表转换为JSON格式并写入指定的文件路径。
|
|
|
+ 如果文件已存在,则覆盖它。
|
|
|
+
|
|
|
+ 参数:
|
|
|
+ data (list): 要转换为JSON的列表。
|
|
|
+ file_path (str): 要写入JSON数据的文件路径。
|
|
|
+ """
|
|
|
+
|
|
|
+ json_data = json.dumps(data, ensure_ascii=False, indent=4)
|
|
|
+ json_data_utf8 = json_data.encode('utf-8')
|
|
|
+
|
|
|
+
|
|
|
+ with open(file_path, 'w') as file:
|
|
|
+
|
|
|
+ file.write(json_data_utf8)
|
|
|
+
|
|
|
|
|
|
|
|
|
def move_xosc_before_simulation(root_path):
|
|
@@ -53,6 +96,9 @@ def upload_simulation(parse_prefix, mp41):
|
|
|
logging.info('上传仿真视频到 %s' % parse_prefix + 'scenario_orig.mp4')
|
|
|
shutil.rmtree(path1)
|
|
|
except Exception as e:
|
|
|
+ error_bag_list = parse_json_to_string_array(error_bag_json)
|
|
|
+ error_bag_list.append(parse_prefix)
|
|
|
+ list_to_json_file(error_bag_list, error_bag_json)
|
|
|
logging.exception("上传视频报错 %s" % str(e))
|
|
|
|
|
|
|
|
@@ -120,6 +166,9 @@ if __name__ == '__main__':
|
|
|
continue
|
|
|
if mp4_done:
|
|
|
continue
|
|
|
+ error_bag_list = parse_json_to_string_array(error_bag_json)
|
|
|
+ if str(parse_prefix_full) in error_bag_list:
|
|
|
+ continue
|
|
|
logging.info("需要生成仿真视频: %s" % str(parse_prefix_full))
|
|
|
parse_prefix_full = str(parse_prefix_full)
|
|
|
local_dir_full = path1 + parse_prefix_full
|