From 600c958924cee4e0863ebcb7bc67cf8263ef2e07 Mon Sep 17 00:00:00 2001 From: iwatake Date: Tue, 17 Sep 2024 17:23:16 +0900 Subject: [PATCH] fix(analyze_topic): treat no yaml file case (#182) Signed-off-by: takeshi.iwanari --- .../make_report_analyze_topic.py | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/report/analyze_topic/make_report_analyze_topic.py b/report/analyze_topic/make_report_analyze_topic.py index 688741c..701d48e 100644 --- a/report/analyze_topic/make_report_analyze_topic.py +++ b/report/analyze_topic/make_report_analyze_topic.py @@ -67,17 +67,20 @@ def make_pages_for_component(path_component: Path, report_name: str, node_html_d topic_html_list = [topic_path.name + '.html' for topic_path in topic_path_list] topic_name_list = [] for i, topic_path in enumerate(topic_path_list): - with open(topic_path.joinpath('stats_FREQUENCY.yaml'), 'r', encoding='utf-8') as f_yaml_freq, \ - open(topic_path.joinpath('stats_PERIOD.yaml'), 'r', encoding='utf-8') as f_yaml_period, \ - open(topic_path.joinpath('stats_LATENCY.yaml'), 'r', encoding='utf-8') as f_yaml_latency: - stats_freq = yaml.safe_load(f_yaml_freq) - stats_period = yaml.safe_load(f_yaml_period) - stats_latency = yaml.safe_load(f_yaml_latency) - if len(stats_freq) == 0: - continue - topic_name = stats_freq[0]['topic_name'] - topic_name_list.append(topic_name) - render_detail_page(path_component.joinpath(topic_html_list[i]), topic_path.name, f'Topic: {topic_name}', report_name, stats_freq, stats_period, stats_latency, node_html_dict) + try: + with open(topic_path.joinpath('stats_FREQUENCY.yaml'), 'r', encoding='utf-8') as f_yaml_freq, \ + open(topic_path.joinpath('stats_PERIOD.yaml'), 'r', encoding='utf-8') as f_yaml_period, \ + open(topic_path.joinpath('stats_LATENCY.yaml'), 'r', encoding='utf-8') as f_yaml_latency: + stats_freq = yaml.safe_load(f_yaml_freq) + stats_period = yaml.safe_load(f_yaml_period) + stats_latency = yaml.safe_load(f_yaml_latency) + if len(stats_freq) == 0: + continue + topic_name = stats_freq[0]['topic_name'] + topic_name_list.append(topic_name) + render_detail_page(path_component.joinpath(topic_html_list[i]), topic_path.name, f'Topic: {topic_name}', report_name, stats_freq, stats_period, stats_latency, node_html_dict) + except: + continue render_index_page(path_component.joinpath('index.html'), f'Topic: {path_component.name}', report_name, topic_name_list, topic_html_list)