|
@@ -127,47 +127,53 @@ if __name__ == '__main__':
|
|
endpoint = 'oss-cn-beijing-gqzl-d01-a.ops.gqzl-cloud.com'
|
|
endpoint = 'oss-cn-beijing-gqzl-d01-a.ops.gqzl-cloud.com'
|
|
bucket = oss2.Bucket(auth, endpoint, 'open-bucket')
|
|
bucket = oss2.Bucket(auth, endpoint, 'open-bucket')
|
|
while True:
|
|
while True:
|
|
- logging.info("开始新一轮扫描")
|
|
|
|
- local_delete_list = []
|
|
|
|
- oss_delete_list = []
|
|
|
|
- prefix_list = []
|
|
|
|
- # 2 获取已经上传完成的所有目录并分组
|
|
|
|
- all_prefix_set = set()
|
|
|
|
- for obj1 in oss2.ObjectIterator(bucket, prefix=key1):
|
|
|
|
- # 获取csv
|
|
|
|
- if 'data_parse' in str(obj1.key) and str(obj1.key).count('/') == 4:
|
|
|
|
- all_prefix_set.add('/'.join(str(obj1.key).split('/')[:-1]) + '/')
|
|
|
|
- for obj2_key in all_prefix_set:
|
|
|
|
- xosc_done = False
|
|
|
|
- mp4_done = False
|
|
|
|
- for obj3 in oss2.ObjectIterator(bucket, prefix=obj2_key):
|
|
|
|
- if '/scenario.xosc' in str(obj3.key):
|
|
|
|
- xosc_done = True
|
|
|
|
- if '/scenario_orig.mp4' in str(obj3.key):
|
|
|
|
- mp4_done = True
|
|
|
|
- if not xosc_done or mp4_done:
|
|
|
|
- continue
|
|
|
|
-
|
|
|
|
- logging.info("需要生成仿真视频: %s" % obj2_key)
|
|
|
|
- parse_prefix_full = obj2_key
|
|
|
|
- local_dir_full = path1 + parse_prefix_full
|
|
|
|
- if not os.path.exists(local_dir_full):
|
|
|
|
- os.makedirs(local_dir_full)
|
|
|
|
- # 下载两个csv
|
|
|
|
- root_path1 = local_dir_full + 'orig/'
|
|
|
|
- if not os.path.exists(root_path1):
|
|
|
|
- os.makedirs(root_path1)
|
|
|
|
-
|
|
|
|
- bucket.get_object_to_file(parse_prefix_full + 'simulation.xosc', root_path1 + 'scenario_orig.xosc')
|
|
|
|
- local_delete_list.append(root_path1 + 'scenario_orig.xosc')
|
|
|
|
- move_xosc_before_simulation(root_path1)
|
|
|
|
- simulation(parse_prefix_full, root_path1 + 'simulation.mp4')
|
|
|
|
-
|
|
|
|
- # 删除本地临时文件
|
|
|
|
- if len(local_delete_list) > 0:
|
|
|
|
- for local_delete in local_delete_list:
|
|
|
|
|
|
+ try:
|
|
|
|
+ logging.info("开始新一轮扫描")
|
|
|
|
+ local_delete_list = []
|
|
|
|
+ oss_delete_list = []
|
|
|
|
+ prefix_list = []
|
|
|
|
+ # 2 获取已经上传完成的所有目录并分组
|
|
|
|
+ for obj1 in oss2.ObjectIterator(bucket, prefix=key1):
|
|
try:
|
|
try:
|
|
- os.remove(local_delete)
|
|
|
|
|
|
+ # 获取合并后的包
|
|
|
|
+ merged_bag_object_key = str(obj1.key)
|
|
|
|
+ if 'data_merge' in str(obj1.key) and str(obj1.key).endswith('.bag'):
|
|
|
|
+ merged_bag_object_key_split = merged_bag_object_key.split('/')
|
|
|
|
+ merged_prefix = '/'.join(merged_bag_object_key_split[:-1])
|
|
|
|
+ parse_prefix = merged_prefix.replace('data_merge', 'data_parse')
|
|
|
|
+ parse_prefix_full = merged_bag_object_key.replace('data_merge', 'data_parse')[:-4] + '/'
|
|
|
|
+ xosc_done = False
|
|
|
|
+ mp4_done = False
|
|
|
|
+ for obj3 in oss2.ObjectIterator(bucket, prefix=str(parse_prefix_full)):
|
|
|
|
+ if '/scenario.xosc' in str(obj3.key):
|
|
|
|
+ xosc_done = True
|
|
|
|
+ if '/scenario_orig.mp4' in str(obj3.key):
|
|
|
|
+ mp4_done = True
|
|
|
|
+ if not xosc_done or mp4_done:
|
|
|
|
+ continue
|
|
|
|
+
|
|
|
|
+ logging.info("需要生成仿真视频: %s" % str(parse_prefix_full))
|
|
|
|
+ parse_prefix_full = str(parse_prefix_full)
|
|
|
|
+ local_dir_full = path1 + parse_prefix_full
|
|
|
|
+ if not os.path.exists(local_dir_full):
|
|
|
|
+ os.makedirs(local_dir_full)
|
|
|
|
+ # 下载两个csv
|
|
|
|
+ root_path1 = local_dir_full + 'orig/'
|
|
|
|
+ if not os.path.exists(root_path1):
|
|
|
|
+ os.makedirs(root_path1)
|
|
|
|
+ bucket.get_object_to_file(parse_prefix_full + 'simulation.xosc', root_path1 + 'scenario_orig.xosc')
|
|
|
|
+ local_delete_list.append(root_path1 + 'scenario_orig.xosc')
|
|
|
|
+ move_xosc_before_simulation(root_path1)
|
|
|
|
+ simulation(parse_prefix_full, root_path1 + 'simulation.mp4')
|
|
except Exception as e:
|
|
except Exception as e:
|
|
- logging.exception("删除本地临时文件报错: %s" % str(e))
|
|
|
|
- time.sleep(sleep_time)
|
|
|
|
|
|
+ logging.exception("局部异常处理: %s", str(e))
|
|
|
|
+ # 删除本地临时文件
|
|
|
|
+ if len(local_delete_list) > 0:
|
|
|
|
+ for local_delete in local_delete_list:
|
|
|
|
+ try:
|
|
|
|
+ os.remove(local_delete)
|
|
|
|
+ except Exception as e:
|
|
|
|
+ logging.exception("删除本地临时文件报错: %s" % str(e))
|
|
|
|
+ time.sleep(sleep_time)
|
|
|
|
+ except Exception as e:
|
|
|
|
+ logging.exception("全局异常处理: %s", str(e))
|