2323
2424LOG_NAME = 'test_ntp'
2525MODULE_REPORT_FILE_NAME = 'ntp_report.j2.html'
26+ MODULE_REPORT_STYLED_FILE_NAME = 'ntp_report.jinja2'
2627NTP_SERVER_CAPTURE_FILE = '/runtime/network/ntp.pcap'
2728STARTUP_CAPTURE_FILE = '/runtime/device/startup.pcap'
2829MONITOR_CAPTURE_FILE = '/runtime/device/monitor.pcap'
@@ -142,7 +143,7 @@ def generate_module_report(self):
142143
143144 # Generate the HTML table with the count column
144145 for (src , dst , typ ,
145- version ), avg_diff in average_time_between_requests .items ():
146+ version ), avg_diff in average_time_between_requests .items ():
146147 cnt = len (timestamps [(src , dst , typ , version )])
147148
148149 # Sync Average only applies to client requests
@@ -169,23 +170,42 @@ def generate_module_report(self):
169170 rows_on_page = ((page_useful_space ) // row_height ) - 1
170171 start = 0
171172 report_html = ''
173+ report_html_styled = ''
172174 for page in range (pages + 1 ):
173175 end = start + min (len (module_table_data ), rows_on_page )
174176 module_header_repr = module_header if page == 0 else None
175- page_html = template .render (base_template = self ._base_template_file ,
176- module_header = module_header_repr ,
177- summary_headers = summary_headers ,
178- summary_data = summary_data ,
179- module_data_headers = module_data_headers ,
180- module_data = module_table_data [start :end ])
177+ page_html = template .render (
178+ base_template = self ._base_template_file ,
179+ module_header = module_header_repr ,
180+ summary_headers = summary_headers ,
181+ summary_data = summary_data ,
182+ module_data_headers = module_data_headers ,
183+ module_data = module_table_data [start :end ]
184+ )
185+ page_html_styled = template .render (
186+ base_template = self ._base_template_file_preview ,
187+ module_header = module_header_repr ,
188+ summary_headers = summary_headers ,
189+ summary_data = summary_data ,
190+ module_data_headers = module_data_headers ,
191+ module_data = module_table_data [start :end ]
192+ )
181193 report_html += page_html
194+ report_html_styled += page_html_styled
182195 start = end
183196
184197 LOGGER .debug ('Module report:\n ' + report_html )
185198
186199 # Use os.path.join to create the complete file path
187200 report_path = os .path .join (self ._results_dir , MODULE_REPORT_FILE_NAME )
188201
202+ # Use os.path.join to create the complete file path for styled report
203+ report_path_styled = os .path .join (
204+ self ._results_dir , MODULE_REPORT_STYLED_FILE_NAME
205+ )
206+ # Generate the styled report for preview
207+ self ._render_styled_report (report_html_styled , report_path_styled )
208+
189209 # Write the content to a file
190210 with open (report_path , 'w' , encoding = 'utf-8' ) as file :
191211 file .write (report_html )
0 commit comments