[Fuego] [PATCH 3/3] ftc: gen-report: Add support csv formatter
Hoang Van Tuyen
tuyen.hoangvan at toshiba-tsdv.com
Fri Mar 2 03:36:40 UTC 2018
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
--
================================================================
Hoang Van Tuyen (Mr.)
TOSHIBA SOFTWARE DEVELOPMENT (VIETNAM) CO., LTD.
16th Floor, VIT Building, 519 Kim Ma Str., Ba Dinh Dist., Hanoi, Vietnam
Tel: 84-4-22208801 (Company) - Ext.251
Fax: 84-4-22208802 (Company)
Email: tuyen.hoangvan at toshiba-tsdv.com
================================================================
--
This mail was scanned by BitDefender
For more information please visit http://www.bitdefender.com
More information about the Fuego
mailing list