mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-10-30 18:27:53 +00:00 
			
		
		
		
	lf_report.py : added selectable timestamd to html and pdf output, lf_check.py : formatting output
This commit is contained in:
		| @@ -197,6 +197,18 @@ class lf_report(): | ||||
|             print("write_html failed") | ||||
|         return self.write_output_html | ||||
|  | ||||
|     def write_html_with_timestamp(self):  | ||||
|         self.write_output_html = "{}/{}-{}".format(self.path_date_time,self.date,self.output_html) | ||||
|         print("write_output_html: {}".format(self.write_output_html)) | ||||
|         try: | ||||
|             test_file = open(self.write_output_html, "w") | ||||
|             test_file.write(self.html) | ||||
|             test_file.close() | ||||
|         except: | ||||
|             print("write_html failed") | ||||
|         return self.write_output_html | ||||
|  | ||||
|  | ||||
|     # https://wkhtmltopdf.org/usage/wkhtmltopdf.txt | ||||
|     # page_size A4, A3, Letter, Legal | ||||
|     # orientation Portrait , Landscape | ||||
| @@ -210,7 +222,21 @@ class lf_report(): | ||||
|                         'page-size': _page_size}  # prevent error Blocked access to file | ||||
|             self.write_output_pdf = str(self.path_date_time)+'/'+ str(self.output_pdf) | ||||
|             pdfkit.from_file(self.write_output_html, self.write_output_pdf, options=options) | ||||
|             pass | ||||
|  | ||||
|     # https://wkhtmltopdf.org/usage/wkhtmltopdf.txt | ||||
|     # page_size A4, A3, Letter, Legal | ||||
|     # orientation Portrait , Landscape | ||||
|     def write_pdf_with_timestamp(self, _page_size = 'A4', _orientation = 'Portrait'): | ||||
|             # write logic to generate pdf here | ||||
|             # wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb | ||||
|             # sudo apt install ./wkhtmltox_0.12.6-1.focal_amd64.deb | ||||
|              | ||||
|             options = {"enable-local-file-access" : None, | ||||
|                         'orientation': _orientation, | ||||
|                         'page-size': _page_size}  # prevent error Blocked access to file | ||||
|             self.write_output_pdf = "{}/{}-{}".format(self.path_date_time,self.date,self.output_pdf) | ||||
|             pdfkit.from_file(self.write_output_html, self.write_output_pdf, options=options) | ||||
|  | ||||
|  | ||||
|     def generate_report(self): | ||||
|         self.write_html()             | ||||
|   | ||||
| @@ -217,8 +217,11 @@ class lf_check(): | ||||
|                 self.html_results += """ | ||||
|                     <tr><td>""" + str(test) + """</td><td class='scriptdetails'>""" + str(command) + """</td> | ||||
|                 <td style="""+ str(background) + """>""" + str(self.test_result) + """  | ||||
|                 <td><a href=""" + str(stdout_log_txt) + """ target=\"_blank\">STDOUT</a></td> | ||||
|                 <td><a href=""" + str(stderr_log_txt) + """ target=\"_blank\">STDERR</a></td></tr>"""  | ||||
|                 <td><a href=""" + str(stdout_log_txt) + """ target=\"_blank\">STDOUT</a></td>""" | ||||
|                 if self.test_result == "Failure": | ||||
|                     self.html_results += """<td><a href=""" + str(stderr_log_txt) + """ target=\"_blank\">STDERR</a></td>""" | ||||
|                 else: | ||||
|                     self.html_results += """</tr>"""  | ||||
|  | ||||
|                 row = [test,command,self.test_result,stdout_log_txt,stderr_log_txt] | ||||
|                 print("row: {}".format(row)) | ||||
| @@ -280,12 +283,12 @@ for running scripts listed in lf_check_config.ini | ||||
|     report.build_banner() | ||||
|     report.set_table_title("LF Check Test Results") | ||||
|     report.build_table_title() | ||||
|     # custom html (maybe try different) | ||||
|     html_results = check.get_html_results() | ||||
|     #print("html_results {}".format(html_results)) | ||||
|     report.set_custom_html(html_results) | ||||
|     report.build_custom() | ||||
|     report.write_html() | ||||
|     report.write_html_with_timestamp() | ||||
|     report.write_pdf_with_timestamp() | ||||
|  | ||||
|  | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Chuck SmileyRekiere
					Chuck SmileyRekiere