def log_thread_status(file_path, thread_name, run_info): """ @type file_path:str @type thread_name:str @type run_info:reporting.run_info.RunInfo """ file_content = """ <tr> <td class=\"configOrTest\">T</td> <td class=\"testName\" ><a href = 'threads/""" + thread_name + """.html' target = \"logs\"> <div id='""" + run_info.status + "'>" + thread_name + """</div> </a> </td> </tr > """ write_str_to_file(file_path + "/index.html", file_content)
def log_validation_status(file_path, validation_status): """ @type file_path: str @type validation_status: dict """ i = 0 for key, value in validation_status.iteritems(): if i >= 1: break color = 'green' if not key: color = 'red' file_content = table_entry_top + "<font color='" + color + "'>" + str( validation_status) file_content += "</font>" + table_entry_bottom write_str_to_file(file_path, file_content) i += 1
def log_entry(file_path, request, request_execution_result): """ @type file_path: str @type request: jmx_interaction.structures.RequestStructure @type request_execution_result: dict """ entry_id = str(random.random() * random.choice([10, 20, 30, 100, 500, 1000, 10000, 100000])) diff_operations_div_id = "diffOperations_" + entry_id diff_content_table_id = "diffContent_" + entry_id file_content = table_entry_top + """<pre id='""" + diff_operations_div_id + """' class ='diffContentTableClass'> """ + html.escape(request.__str__()) + """</pre> <pre id='""" + diff_content_table_id + """' style='display: none'>\n """ + html.escape(str(request_execution_result)) + "</pre>" file_content += table_entry_bottom write_str_to_file(file_path, file_content)
def log_common_header(file_path, title): """ @type file_path:str @type title:str """ file_content = """ <html> <head> <META http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"> <title>""" + title + """</title> <link href=\"css/classes.css\" type=\" text/css\" rel=\"stylesheet\"> </head> <body> <table class=\"clear\"> <tr> <th colspan=\"2\"> <div class=\"title\"> <div id=\"${temporary_status}\">""" + title + """</div> </div> </th> </tr> <tr> <td class=\"topLine\" colspan=\"2\"> <div id=\"skipped\">Started at ${temporary_start_time} </div> </td> </tr> <tr> <td colspan=\"2\"> <div id=\"skipped\">Finished at ${temporary_stop_time} </div> </td> </tr> <tr> <td class=\"topBottomLines\" colspan=\"2\"> <div id=\"skipped\" > Duration ${temporary_duration} </div> </td > </tr > """ write_str_to_file(file_path + "/index.html", file_content)
def log_thread_footer(file_path): """ @type file_path: str """ footer_content = """ <script language=\"javascript\" type=\"text/javascript\">\n function expandCollapse(id){\n var element = document.getElementById('diffContent_'+id);\n var currentElement = document.getElementById('btn_'+id);\n if(element.style.display == 'none'){ element.style.display = 'block'; currentElement.value = '--Collapse'; } else{ element.style.display = 'none'; currentElement.value = '--Expand' } }\n function addButton(toElement, id) {\n var btn = document.createElement(\"input\");\n btn.setAttribute(\"type\", \"button\");\n btn.setAttribute(\"value\", \"--Expand\");\n btn.setAttribute(\"name\", id);\n btn.setAttribute(\"id\", 'btn_'+id);\n btn.onclick = function(){expandCollapse(id);}\n var foo = document.getElementById(toElement);\n foo.appendChild(btn);}\n window.onload = function(){\n var tables = document.getElementsByClassName(\"diffContentTableClass\");\n for (i = 0; i < tables.length; i++) {\n var id = tables[i].id;\n id=id.substring(id.indexOf('_')+1);\n addButton('diffOperations_' + id, id);\n }\n }\n</script>\n </table> </body> </html>""" write_str_to_file(file_path, footer_content)
def log_common_footer(file_path, common_run_info): """ @type file_path:str @type common_run_info:reporting.run_info.RunInfo """ file_content = """ </table> </body> </html>""" write_str_to_file(file_path + "/index.html", file_content) replace_in_file(file_path + "/index.html", {"${temporary_status}": common_run_info.status, "${temporary_start_time}": get_date_as_string(common_run_info.start), "${temporary_stop_time}": get_date_as_string(common_run_info.stop), "${temporary_duration}": get_time_as_string( common_run_info.get_duration())}) target_file_name = "" for file_name in os.listdir(file_path + "/threads"): target_file_name = file_name frame_content = """ <html><head><link href=\"main.css\"/></head><frameset cols=\"20%,80%\"> <frame src=\"index.html\" name=\"menu\"> <frame src=\"threads/""" + target_file_name + """\" name=\"logs\"></frameset></html> """ write_str_to_file(file_path + "/index.frame.html", frame_content) write_str_to_file(file_path + "/css/main.css", styles.getMainCssFile) write_str_to_file(file_path + "/css/composite.css", styles.getTestCssFile) write_str_to_file(file_path + "/css/classes.css", styles.getClassCssFile) str_status_result = "GENERAL_RUN_INFO:" if common_run_info.status != TestStatus.PASSED: str_status_result += "FAILED" else: str_status_result += "PASSED" print str_status_result
def log_thread_header(file_path, thread_name): """ @type file_path: str @type thread_name: str """ title = thread_name header_content = """ <html> <head> <META http-equiv="Content-Type\" content=\"text/html; charset=UTF-8\"> <title>""" + title + """</title> <link href=\"../css/composite.css\" type=\"text/css\" rel=\"stylesheet\"> </head> <body> <h2 class=\"testName\" id=\"${temporary_status}\">""" + title + """</h2> <h3> Started: ${temporary_start_time} </h3> <h3> Finished: ${temporary_stop_time} </h3> <h3> Time Spend: ${temporary_duration} </h3> <div class=\"invisible\"></div> <table class=\"testResults\"> """ write_str_to_file(file_path, header_content)