diff --git a/py-scripts/lf_report.py b/py-scripts/lf_report.py index 4aaeb679..310c54c0 100755 --- a/py-scripts/lf_report.py +++ b/py-scripts/lf_report.py @@ -37,6 +37,7 @@ class lf_report(): #_path the report directory under which the report directories will be created. _path = "/home/lanforge/report-data", _alt_path = "", + _results_dir_name = "LANforge_Test_Results", _output_format = 'html', # pass in on the write functionality, current not used _dataframe="", _title="LANForge Test Run Heading", @@ -87,7 +88,7 @@ class lf_report(): self.current_path = os.path.dirname(os.path.abspath(__file__)) # pass in _date to allow to change after construction - self.set_date_time_directory(_date) + self.set_date_time_directory(_date,_results_dir_name) self.build_date_time_directory() # move the banners and candela images to report path @@ -118,13 +119,14 @@ class lf_report(): def set_path(self,_path): self.path = _path - - def set_date_time_directory(self,_date): + + def set_date_time_directory(self,_date,_results_dir_name): self.date = _date + self.results_dir_name = _results_dir_name if self.date != "": - self.date_time_directory = self.date + self.date_time_directory = str(self.date) + str("_") + str(self.results_dir_name) else: - self.date_time_directory = str(datetime.datetime.now().strftime("%Y-%m-%d-%H-h-%M-m-%S-s")).replace(':','-') + self.date_time_directory = str(datetime.datetime.now().strftime("%Y_%m_%d_%H_%M_%S_")).replace(':','-') + str(self.results_dir_name) #def set_date_time_directory(self,date_time_directory): # self.date_time_directory = date_time_directory @@ -133,7 +135,6 @@ class lf_report(): def build_date_time_directory(self): if self.date_time_directory == "": self.set_date_time_directory() - #try: self.path_date_time = os.path.join(self.path, self.date_time_directory) print("path_date_time {}".format(self.path_date_time)) try: @@ -179,6 +180,11 @@ class lf_report(): def get_report_path(self): return self.path_date_time + def file_add_path(self, file): + output_file = str(self.path_date_time)+'/'+ str(file) + print("output file {}".format(output_file)) + return output_file + def write_html(self): self.write_output_html = str(self.path_date_time)+'/'+ str(self.output_html) print("write_output_html: {}".format(self.write_output_html)) diff --git a/py-scripts/lf_report_test.py b/py-scripts/lf_report_test.py index 130a0b28..aea6228d 100644 --- a/py-scripts/lf_report_test.py +++ b/py-scripts/lf_report_test.py @@ -31,6 +31,13 @@ if __name__ == "__main__": #report = lf_report(_dataframe=dataframe) report = lf_report() + + report_path = report.get_path() + report_path_date_time = report.get_path_date_time() + + print("path: {}".format(report_path)) + print("path_date_time: {}".format(report_path_date_time)) + report.set_title("Banner Title One") report.build_banner() #report.set_title("Banner Title Two") diff --git a/py-scripts/lf_snp_test.py b/py-scripts/lf_snp_test.py index 01f08c10..e4c5384d 100755 --- a/py-scripts/lf_snp_test.py +++ b/py-scripts/lf_snp_test.py @@ -54,6 +54,9 @@ import re import csv import random import logging +from lf_report import lf_report +from lf_graph import lf_bar_graph + FORMAT = '%(asctime)s %(name)s %(levelname)s: %(message)s' @@ -1594,18 +1597,6 @@ LANforge GUI what is displayed in the Column and how to access the value with cl if args.radio: radios = args.radio - if args.csv_outfile != None: - current_time = time.strftime("%m_%d_%Y_%H_%M_%S", time.localtime()) - csv_outfile = "{}_{}.csv".format(args.csv_outfile,current_time) - csv_results = "results_{}_{}.csv".format(args.csv_outfile,current_time) - print("csv output file : {}".format(csv_outfile)) - - if args.log: - outfile_log = "{}_{}_output_log.log".format(args.outfile,current_time) - print("output file log: {}".format(outfile_log)) - else: - outfile_log = "stdout" - print("output file log: {}".format(outfile_log)) if args.wait_timeout: wait_timeout = int(args.wait_timeout) @@ -1652,6 +1643,28 @@ LANforge GUI what is displayed in the Column and how to access the value with cl exit(1) print("ap_dict: {}".format(ap_dict)) + # Logging information + report = lf_report() + + if args.csv_outfile != None: + current_time = time.strftime("%m_%d_%Y_%H_%M_%S", time.localtime()) + csv_outfile = "{}_{}.csv".format(args.csv_outfile,current_time) + csv_outfile = report.file_add_path(csv_outfile) + + csv_results = "results_{}_{}.csv".format(args.csv_outfile,current_time) + csv_results = report.file_add_path(csv_results) + print("csv output file : {}".format(csv_outfile)) + print("csv results file : {}".format(csv_results)) + + if args.log: + outfile_log = "{}_{}_output_log.log".format(args.outfile,current_time) + outfile_log = report.file_add_path(outfile_log) + print("output file log: {}".format(outfile_log)) + else: + outfile_log = "stdout" + print("output file log: {}".format(outfile_log)) + + # Set up the log file console_handler = logging.StreamHandler() formatter = logging.Formatter(FORMAT) logg = logging.getLogger(__name__) @@ -2419,6 +2432,17 @@ LANforge GUI what is displayed in the Column and how to access the value with cl else: ip_var_test.passes() logg.info("Full test passed, all connections increased rx rate") + ########################################## + # + # Print out location of results + # + ########################################## + if args.csv_outfile != None: + logg.info("Report CSV: {}".format(csv_outfile)) + logg.info("Report CSV Results: {}".format(csv_results)) + + if args.log: + logg.info("output_log: {}".format(outfile_log)) if __name__ == "__main__": main()