def get_html_summary_table(test_names): """Returns a html string summarizing the tests with these names """ html = """ <table ><tr> <th>Test Name</th> <th>Type</th> <th>Status</th> <th>When?</th> <th>Total runtime (s)</th> """ for name in test_names: res = sqlresults.get_latest_result(name) if not res is None: # Calculate how long ago if not res["success"]: html += """<tr class="failedrow">""" else: html += """<tr>""" html += """<td><a href="%s.htm">%s</a></td>""" % (name, name) html += """<td>%s</td>""" % res['type'] html += """<td>%s</td>""" % res['status'] # Friendly date date = to_datetime(res['date']) html += """<td>%s</td>""" % date.strftime("%b %d, %H:%M:%S") html += """<td>%s</td>""" % res['runtime'] html += """</tr>""" html += """</table>""" return html
def get_html_summary_table(test_names): """Returns a html string summarizing the tests with these names """ html = """ <table ><tr> <th>Test Name</th> <th>Type</th> <th>Status</th> <th>When?</th> <th>Total runtime (s)</th> """ for name in test_names: res = sqlresults.get_latest_result(name) if not res is None: # Calculate how long ago if not res["success"]: html += """<tr class="failedrow">""" else: html += """<tr>""" html += """<td><a href="%s.htm">%s</a></td>""" % (name, name) html += """<td>%s</td>""" % res['type'] html += """<td>%s</td>""" % res['status'] # Friendly date date = datetime.datetime.strptime(res['date'], DATE_STR_FORMAT) html += """<td>%s</td>""" % date.strftime("%b %d, %H:%M:%S") html += """<td>%s</td>""" % res['runtime'] html += """</tr>""" html += """</table>""" return html
def generate_html_report(path, last_num, x_field='revision'): """Make a comprehensive HTML report of runtime history for all tests. Parameters ---------- path :: base path to the report folder last_num :: in the shorter plot, how many SVN revs to show? x_field :: the field to use as the x-axis. 'revision' or 'date' make sense """ basedir = os.path.abspath(path) if not os.path.exists(basedir): os.mkdir(basedir) # Make the CSS file to be used by all HTML make_css_file(path) # Detect if you can do figures dofigs = True # --------- Start the HTML -------------- html = DEFAULT_HTML_HEADER html += """<h1>Mantid System Tests Auto-Generated Report</h1>""" html += """<p><a href="overview_plot.htm">See an overview of performance plots for all tests by clicking here.</a></p> """ if not dofigs: html += """<p class="error">There was an error generating plots. No figures will be present in the report.</p>""" html += """<h2>Run Environment</h2> %s """ % (make_environment_html(sqlresults.get_latest_result())) overview_html = "" # ------ Find the test names of interest ---------------- # Limit with only those tests that exist in the latest rev latest_rev = sqlresults.get_latest_revison() test_names = list( sqlresults.get_all_test_names(" revision = %d" % latest_rev)) test_names.sort() # ------ Find a list of subproject names -------- subprojects = set() for name in test_names: n = name.find(".") if n > 0: subprojects.add(name[:n]) subprojects = list(subprojects) subprojects.sort() html += """<h2>Test Subprojects</h2> <big> <table cellpadding="10"> """ for subproject in subprojects: (filename, this_overview) = generate_html_subproject_report( path, last_num, x_field, subproject) overview_html += this_overview html += """<tr> <td> <a href="%s">%s</a> </td> </tr> """ % (filename, subproject) html += """</table></big>""" # --------- Table with the summary of latest results -------- html += """<h2>Overall Results Summary</h2>""" html += get_html_summary_table(test_names) html += DEFAULT_HTML_FOOTER f = open(os.path.join(basedir, "report.htm"), "w") html = html.replace("\n", os.linesep) # Fix line endings for windows f.write(html) f.close() # -------- Overview of plots ------------ f = open(os.path.join(basedir, "overview_plot.htm"), "w") overview_html = overview_html.replace( "\n", os.linesep) # Fix line endings for windows f.write(overview_html) f.close() print "Report complete!"
def generate_html_report(path, last_num, x_field='revision'): """Make a comprehensive HTML report of runtime history for all tests. Parameters ---------- path :: base path to the report folder last_num :: in the shorter plot, how many SVN revs to show? x_field :: the field to use as the x-axis. 'revision' or 'date' make sense """ basedir = os.path.abspath(path) if not os.path.exists(basedir): os.mkdir(basedir) # Make the CSS file to be used by all HTML make_css_file(path) # Detect if you can do figures dofigs = True try: figure() except: dofigs = False # --------- Start the HTML -------------- html = default_html_header html += """<h1>Mantid System Tests Auto-Generated Report</h1>""" html += """<p><a href="overview_plot.htm">See an overview of performance plots for all tests by clicking here.</a></p> """ if not dofigs: html += """<p class="error">There was an error generating plots. No figures will be present in the report.</p>""" html += """<h2>Run Environment</h2> %s """ % ( make_environment_html(sqlresults.get_latest_result()) ) overview_html = "" # ------ Find the test names of interest ---------------- # Limit with only those tests that exist in the latest rev latest_rev = sqlresults.get_latest_revison() test_names = list(sqlresults.get_all_test_names(" revision = %d" % latest_rev)) test_names.sort() # ------ Find a list of subproject names -------- subprojects = set() for name in test_names: n = name.find(".") if n > 0: subprojects.add( name[:n] ) subprojects = list(subprojects) subprojects.sort() html += """<h2>Test Subprojects</h2> <big> <table cellpadding="10"> """ for subproject in subprojects: (filename, this_overview) = generate_html_subproject_report(path, last_num, x_field, subproject) overview_html += this_overview html += """<tr> <td> <a href="%s">%s</a> </td> </tr> """ % (filename, subproject) html += """</table></big>""" # --------- Table with the summary of latest results -------- html += """<h2>Overall Results Summary</h2>""" html += get_html_summary_table(test_names) # -------- Overall success history graphs ------------ #if dofigs: # # We report the overall success # fig_path = "OverallSuccess.png" # plot_success_count(type='',last_num=last_num, x_field=x_field) # savefig(os.path.join(basedir, fig_path)) # close() # # fig_path2 = "OverallSuccess.ALL.png" # plot_success_count(type='',last_num=-1, x_field=x_field) # savefig(os.path.join(basedir, fig_path2)) # close() # # html += """<h2>Overall Success/Failure</h2> # <img src="%s" /> # <img src="%s" /> # """ % (fig_path, fig_path2) html += default_html_footer f = open(os.path.join(basedir, "report.htm"), "w") html = html.replace("\n", os.linesep) # Fix line endings for windows f.write(html) f.close() # -------- Overview of plots ------------ f = open(os.path.join(basedir, "overview_plot.htm"), "w") overview_html = overview_html.replace("\n", os.linesep) # Fix line endings for windows f.write(overview_html) f.close() print "Report complete!"