Date/Time | -Header | -||
---|---|---|---|
Totals | -Percent | -Hour | -
-
- |
-
Date/Time | +Header | +||
---|---|---|---|
Totals | +Percent | +Hour | +
+
+ |
+
- + +




+ - - + ") + html_contents = insert_string_after(html_contents,"\n","") return html_contents def read_text_from_file(filepath): @@ -1643,7 +1546,7 @@ if __name__ == "__main__": connection_type_counts[connection_type] += 1 #print(f"Count:{connection_type_counts[connection_type]}") continue - + #Compute next and previous dates day_format = "%Y-%m-%d" @@ -1658,10 +1561,27 @@ if __name__ == "__main__": previous_date_str = previous_date.strftime(day_format) # Create graphs of data - yLabels = [f'{i:02d}:00' for i in range(len(columnCounts_2d))] - stacked_Bar_html = create_stacked_bar_graph(columnCounts_2d,columnHeaders,yLabels,html_page_dir+'stacked_bar_'+analysis_date+'.html') - heatmap_html = create_heatmap(columnCounts_2d,columnHeaders,yLabels,html_page_dir+'heatmap_'+analysis_date+'.html') - line_graph_html = create_line_chart(columnCounts_2d,columnHeaders,yLabels,html_page_dir+'line_graph_'+analysis_date+'.html') + + # yLabels = [f'{i:02d}:00' for i in range(len(columnCounts_2d))] + # stacked_Bar_html = create_stacked_bar_graph(columnCounts_2d,columnHeaders,yLabels,html_page_dir+'stacked_bar_'+analysis_date+'.html') + # heatmap_html = create_heatmap(columnCounts_2d,columnHeaders,yLabels,html_page_dir+'heatmap_'+analysis_date+'.html') + # line_graph_html = create_line_chart(columnCounts_2d,columnHeaders,yLabels,html_page_dir+'line_graph_'+analysis_date+'.html') + + columnCounts_2d_dict = transform_to_dict(columnCounts_2d,columnHeaders,analysis_date) + + #Export as json for testing + # with open("/opt/mailstats/html/colCounts_2d.json", "w") as json_file: + # json.dump(columnCounts_2d, json_file) + # with open("/opt/mailstats/html/colCounts_2d-dict", "w") as json_file: + # json.dump(columnCounts_2d_dict, json_file) + # with open("/opt/mailstats/html/keys.json", "w") as json_file: + # json.dump(columnHeaders, json_file) + + if enable_graphs: + create_graph(columnCounts_2d_dict, "line", html_page_dir+"line_graph_"+analysis_date+".png",analysis_date) + create_graph(columnCounts_2d_dict, "bar", html_page_dir+"bar_graph_"+analysis_date+".png",analysis_date) + create_graph(columnCounts_2d_dict, "scatter", html_page_dir+"scatter_graph_"+analysis_date+".png",analysis_date) + create_graph(columnCounts_2d_dict, "pie", html_page_dir+"pie_chart_"+analysis_date+".png",analysis_date) #Now apply the results to the chameleon template - main table # Path to the template file @@ -1682,13 +1602,11 @@ if __name__ == "__main__": reporting_date=analysis_date, title=html_title, version=version_string, nolinks=nolinks, - stacked_bar_graph=stacked_Bar_html, - heatmap=heatmap_html, - line_graph=line_graph_html, PreviousDate=previous_date_str, NextDate=next_date_str, DomainName=DomainName, - SystemName=SystemName + SystemName=SystemName, + enable_graphs=enable_graphs ) except Exception as e: print(f"Chameleon template Exception {e}") @@ -1785,7 +1703,7 @@ if __name__ == "__main__": filepath = html_page_dir+"mailstats_for_"+analysis_date+".html" html_content = read_html_from_file(filepath) # Replace the Navigation by a "See in browser" prompt - replace_str = f"" + replace_str = f"" html_content = replace_between(html_content, "