[Fuego] [PATCH 3/3] ftc: gen-report: Add support csv formatter

Hoang Van Tuyen tuyen.hoangvan at toshiba-tsdv.com
Thu Mar 8 02:50:41 UTC 2018


I re-send the patch in an attachment.


On 3/8/2018 6:10 AM, Tim.Bird at sony.com wrote:
> Please resubmit this whole series.
>   -- Tim
>
>> -----Original Message-----
>> From: fuego-bounces at lists.linuxfoundation.org [mailto:fuego-
>> bounces at lists.linuxfoundation.org] On Behalf Of Hoang Van Tuyen
>> Sent: Thursday, March 01, 2018 7:37 PM
>> To: fuego at lists.linuxfoundation.org
>> Subject: [Fuego] [PATCH 3/3] ftc: gen-report: Add support csv formatter
>>
>> Add a formatter for csv format. The report file is stored in ${report_dir}
>> In future, we will add support viewing the report in the Jenkins interface
>>
>> Signed-off-by: Hoang Van Tuyen <tuyen.hoangvan at toshiba-tsdv.com>
>> ---
>>    engine/scripts/ftc | 17 ++++++++++++++++-
>>    1 file changed, 16 insertions(+), 1 deletion(-)
>>
>> diff --git a/engine/scripts/ftc b/engine/scripts/ftc
>> index e0ed13d..386e9ca 100755
>> --- a/engine/scripts/ftc
>> +++ b/engine/scripts/ftc
>> @@ -2140,6 +2140,18 @@ def gen_excel_report(header_data, report_data,
>> report_dir):
>>        # save the report
>>        workbook.save(report_dir + "report.xlsx")
>>
>> +def gen_csv_report(header_data, report_data, report_dir):
>> +    import csv
>> +
>> +    filename = report_dir + "report.csv"
>> +    # generate header
>> +    with open(filename, "wb") as report:
>> +        writer = csv.writer(report)
>> +        writer.writerows(header_data)
>> +
>> +    # generate lines for this report
>> +        writer.writerows(report_data)
>> +
>>    # generate a report from run results
>>    def do_gen_report(conf, options):
>>        global quiet, verbose
>> @@ -2161,7 +2173,7 @@ def do_gen_report(conf, options):
>>        fmt="txt"
>>        if "--format" in options:
>>            fmt = options[options.index("--format")+1]
>> -        if fmt not in ["txt","html","pdf","excel"]:
>> +        if fmt not in ["txt","html","pdf","excel","csv"]:
>>                error_out("Unsupported format '%s' specified" % fmt)
>>
>>        if "--layout" in options:
>> @@ -2195,6 +2207,9 @@ def do_gen_report(conf, options):
>>        if fmt=="excel":
>>            gen_excel_report(header_data, report_data, report_dir)
>>            sys.exit(0)
>> +    if fmt=="csv":
>> +        gen_csv_report(header_data, report_data, report_dir)
>> +        sys.exit(0)
>>
>>        print report
>>
>> --
>> 2.1.4
>>
>>
>>
>> --
>> This mail was scanned by BitDefender
>> For more information please visit http://www.bitdefender.com
>>
>> _______________________________________________
>> Fuego mailing list
>> Fuego at lists.linuxfoundation.org
>> https://lists.linuxfoundation.org/mailman/listinfo/fuego

_______________________________________________
Fuego mailing list
Fuego at lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/fuego

-------------- next part --------------
>From f65045178c538e4178af4e9dd3496d0c7498179a Mon Sep 17 00:00:00 2001
From: Hoang Van Tuyen <tuyen.hoangvan at toshiba-tsdv.com>
Date: Fri, 2 Mar 2018 10:01:50 +0700
Subject: [PATCH 3/3] ftc: gen-report: Add support csv formatter

Add a formatter for csv format. The report file is stored in ${report_dir}
In future, we will add support viewing the report in the Jenkins interface

Signed-off-by: Hoang Van Tuyen <tuyen.hoangvan at toshiba-tsdv.com>
---
 engine/scripts/ftc | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/engine/scripts/ftc b/engine/scripts/ftc
index e0ed13d..386e9ca 100755
--- a/engine/scripts/ftc
+++ b/engine/scripts/ftc
@@ -2140,6 +2140,18 @@ def gen_excel_report(header_data, report_data, report_dir):
     # save the report
     workbook.save(report_dir + "report.xlsx")
 
+def gen_csv_report(header_data, report_data, report_dir):
+    import csv
+
+    filename = report_dir + "report.csv"
+    # generate header
+    with open(filename, "wb") as report:
+        writer = csv.writer(report)
+        writer.writerows(header_data)
+
+    # generate lines for this report
+        writer.writerows(report_data)
+
 # generate a report from run results
 def do_gen_report(conf, options):
     global quiet, verbose
@@ -2161,7 +2173,7 @@ def do_gen_report(conf, options):
     fmt="txt"
     if "--format" in options:
         fmt = options[options.index("--format")+1]
-        if fmt not in ["txt","html","pdf","excel"]:
+        if fmt not in ["txt","html","pdf","excel","csv"]:
             error_out("Unsupported format '%s' specified" % fmt)
 
     if "--layout" in options:
@@ -2195,6 +2207,9 @@ def do_gen_report(conf, options):
     if fmt=="excel":
         gen_excel_report(header_data, report_data, report_dir)
         sys.exit(0)
+    if fmt=="csv":
+        gen_csv_report(header_data, report_data, report_dir)
+        sys.exit(0)
 
     print report
 
-- 
2.1.4

-------------- next part --------------
-- 
This mail was scanned by BitDefender
For more information please visit http://www.bitdefender.com


More information about the Fuego mailing list