From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Hoang Van Tuyen Message-ID: <48ee9177-bd98-d609-5328-b21a6f110e1e@toshiba-tsdv.com> Date: Thu, 22 Feb 2018 17:51:06 +0700 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------BD6038D0A1E4B78F5D13F303" Subject: [Fuego] [PATCH 2/2] ftc: gen_report: Add new functions for getting data to, generate the report List-Id: Mailing list for the Fuego test framework List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "fuego@lists.linuxfoundation.org" This is a multi-part message in MIME format. --------------BD6038D0A1E4B78F5D13F303 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hello Tim, I am working on gen-report feature (support several other format like html, pdf, ...). The attached patch defines two new functions used for generating data for the report. Could you please check it? =========================================================================== For reusability, the two functions have been defined with purpose like below: gen_header_for_report: Get value for fields in the header_fields (test, board, report_date, ...). gen_data_for_report: Get value for fields in the fields variable (test_name, spec, timestamp, ...). This commit also modifies gen_text_report function to compatible with defining the two new funtions. Also, correct some grammar mistakes. Signed-off-by: Hoang Van Tuyen --- engine/scripts/ftc | 78 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 47 insertions(+), 31 deletions(-) diff --git a/engine/scripts/ftc b/engine/scripts/ftc index 44e4da7..a2f5a78 100755 --- a/engine/scripts/ftc +++ b/engine/scripts/ftc @@ -71,7 +71,7 @@ def pvar(name): quiet = 0 verbose = 0 -use_statusouput = 1 +use_statusoutput = 1 server = jenkins.Jenkins('http://localhost:8080/fuego') # keep configuration file in /fuego-ro/conf area @@ -1745,7 +1745,7 @@ class where_class: found = False try: run_value = run.__dict__[self.field_name] - found = true + found = True except: pass @@ -1849,13 +1849,8 @@ def do_list_runs(conf, options): sys.exit(0) -def gen_text_report(run_list, run_map, header_fields, fields): - # generate header - ddash_line="="*70 + "\n" - report = ddash_line - title = "Fuego Test Report" - report += " **** %s ****\n" % title - report_date = time.strftime("%Y-%m-%d_%H:%M:%S") +def gen_header_for_report(run_list, run_map, header_fields, fields): + header_report = "" for field in header_fields: if field=="report_date": @@ -1875,22 +1870,14 @@ def gen_text_report(run_list, run_map, header_fields, fields): else: for value in value_list[1:]: val_str += ", "+value + header_report += " %-20s: %s\n" % (field, val_str) - line = " %-20s: %s\n" % (field, val_str) - report += line - report += ddash_line + return header_report +def gen_data_for_report(run_list, run_map, header_fields, fields): + data_to_report = [] # generate list - # start with a header line - dash_line = "-"*(21*len(fields)+2) + "\n" - report += dash_line - line = " " - for field in fields: - line += "%-20s " % field - report += line + "\n" - report += dash_line - # now loop over the runs, printing the requested report fields # if tguid is a field, we'll print a line for each tguid # otherwise, it's a line per test @@ -1921,10 +1908,6 @@ def gen_text_report(run_list, run_map, header_fields, fields): continue # format each column per row (ie per line) - line = " " - start_sep = " " - mid_sep = " " - end_sep = "" pos = 0 for field in fields: if field=="tguid": @@ -1937,15 +1920,48 @@ def gen_text_report(run_list, run_map, header_fields, fields): tguid_name = "" value = run.get_field(field, tguid_name) if pos==0: - line += "%-20s%s" % (value, start_sep) + data_to_report.append((value,field)) else: - line += "%-20s" % (value) if pos