* [Fuego] [PATCH 1/3] ftc: gen-report: Add pdf formatter
@ 2018-03-02 3:36 Hoang Van Tuyen
2018-03-07 23:04 ` Tim.Bird
0 siblings, 1 reply; 4+ messages in thread
From: Hoang Van Tuyen @ 2018-03-02 3:36 UTC (permalink / raw)
To: fuego
Add a formatter for pdf report output. By default, the pdf
output file is stored in /fuego-rw/report with name report.pdf.
It uses a reportlab python library for generating the report,
So, please make sure that the library is available in the system.
Signed-off-by: Hoang Van Tuyen <tuyen.hoangvan@toshiba-tsdv.com>
---
engine/scripts/ftc | 50 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 49 insertions(+), 1 deletion(-)
diff --git a/engine/scripts/ftc b/engine/scripts/ftc
index c6a0f3d..0b99f94 100755
--- a/engine/scripts/ftc
+++ b/engine/scripts/ftc
@@ -2037,6 +2037,46 @@ def gen_html_report(header_data, report_data):
return report
+# add page number for a pdf file
+def add_page_number(canvas, doc):
+ from reportlab.lib.units import mm
+
+ page_num = canvas.getPageNumber()
+ text = "Page %s" % page_num
+ canvas.drawRightString(200*mm, 20*mm, text)
+
+def gen_pdf_report(header_data, report_data, report_dir):
+ from reportlab.lib import colors
+ from reportlab.lib.pagesizes import A4
+ from reportlab.lib.styles import getSampleStyleSheet
+ from reportlab.platypus import SimpleDocTemplate, Table,
TableStyle, Paragraph
+
+ # create a pdf file
+ doc = SimpleDocTemplate(report_dir + "report.pdf", pagesize=A4)
+ elements = []
+
+ # generate header
+ styles = getSampleStyleSheet()
+ elements.append(Paragraph("Fuego Test Report\n", styles["Heading1"]))
+ for field,val_str in header_data:
+ elements.append(Paragraph("%s: %s\n" % (field, val_str),
styles["Normal"]))
+
+ # generate lines for this report
+ fields = report_data[0]
+
+ # create the table with a header row in each page
+ report_data = [[Paragraph(str(cell), styles["Normal"]) for cell in
row] for row in report_data]
+ table = Table(report_data, repeatRows=1, colWidths=[75,75])
+
+ # format for table in the report file
+ table.setStyle(TableStyle([("INNERGRID", (0, 0), (-1, -1), 0.25,
colors.black),
+ ("BOX", (0, 0), (-1, -1), 0.25,
colors.black),
+ ("BACKGROUND",(0, 0), (len(fields) -
1,0), colors.silver),
+ ("VALIGN",(0, 0), (-1, -1), "MIDDLE")]))
+
+ elements.append(table)
+ doc.build(elements, onFirstPage=add_page_number,
onLaterPages=add_page_number)
+
# generate a report from run results
def do_gen_report(conf, options):
global quiet, verbose
@@ -2058,7 +2098,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"]:
+ if fmt not in ["txt","html","pdf"]:
error_out("Unsupported format '%s' specified" % fmt)
if "--layout" in options:
@@ -2073,6 +2113,11 @@ def do_gen_report(conf, options):
#fields = ["test_name", "spec", "board", "timestamp", "tguid",
"status"]
#rfields = ["test_name", "spec", "board", "timestamp",
"tguid", "tguid:measure", "tguid:unit", "tguid:status", "tguid:result"]
+ # create a directory to save report files
+ report_dir = "/fuego-rw/report/"
+ if not os.path.exists(report_dir):
+ os.makedirs(report_dir)
+
# get data for report
header_data = get_report_header_data(run_list, run_map, header_fields)
report_data = get_report_data(run_list, run_map, fields)
@@ -2081,6 +2126,9 @@ def do_gen_report(conf, options):
report = gen_text_report(header_data, report_data)
if fmt=="html":
report = gen_html_report(header_data, report_data)
+ if fmt=="pdf":
+ gen_pdf_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@toshiba-tsdv.com
================================================================
--
This mail was scanned by BitDefender
For more information please visit http://www.bitdefender.com
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Fuego] [PATCH 1/3] ftc: gen-report: Add pdf formatter
2018-03-02 3:36 [Fuego] [PATCH 1/3] ftc: gen-report: Add pdf formatter Hoang Van Tuyen
@ 2018-03-07 23:04 ` Tim.Bird
2018-03-08 2:48 ` Hoang Van Tuyen
0 siblings, 1 reply; 4+ messages in thread
From: Tim.Bird @ 2018-03-07 23:04 UTC (permalink / raw)
To: tuyen.hoangvan, fuego
This patch also has wrapping issues.
-- Tim
> -----Original Message-----
> From: fuego-bounces@lists.linuxfoundation.org [mailto:fuego-
> bounces@lists.linuxfoundation.org] On Behalf Of Hoang Van Tuyen
> Sent: Thursday, March 01, 2018 7:36 PM
> To: fuego@lists.linuxfoundation.org
> Subject: [Fuego] [PATCH 1/3] ftc: gen-report: Add pdf formatter
>
> Add a formatter for pdf report output. By default, the pdf
> output file is stored in /fuego-rw/report with name report.pdf.
>
> It uses a reportlab python library for generating the report,
> So, please make sure that the library is available in the system.
>
> Signed-off-by: Hoang Van Tuyen <tuyen.hoangvan@toshiba-tsdv.com>
> ---
> engine/scripts/ftc | 50
> +++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 49 insertions(+), 1 deletion(-)
>
> diff --git a/engine/scripts/ftc b/engine/scripts/ftc
> index c6a0f3d..0b99f94 100755
> --- a/engine/scripts/ftc
> +++ b/engine/scripts/ftc
> @@ -2037,6 +2037,46 @@ def gen_html_report(header_data, report_data):
>
> return report
>
> +# add page number for a pdf file
> +def add_page_number(canvas, doc):
> + from reportlab.lib.units import mm
> +
> + page_num = canvas.getPageNumber()
> + text = "Page %s" % page_num
> + canvas.drawRightString(200*mm, 20*mm, text)
> +
> +def gen_pdf_report(header_data, report_data, report_dir):
> + from reportlab.lib import colors
> + from reportlab.lib.pagesizes import A4
> + from reportlab.lib.styles import getSampleStyleSheet
> + from reportlab.platypus import SimpleDocTemplate, Table,
> TableStyle, Paragraph
> +
> + # create a pdf file
> + doc = SimpleDocTemplate(report_dir + "report.pdf", pagesize=A4)
> + elements = []
> +
> + # generate header
> + styles = getSampleStyleSheet()
> + elements.append(Paragraph("Fuego Test Report\n", styles["Heading1"]))
> + for field,val_str in header_data:
> + elements.append(Paragraph("%s: %s\n" % (field, val_str),
> styles["Normal"]))
> +
> + # generate lines for this report
> + fields = report_data[0]
> +
> + # create the table with a header row in each page
> + report_data = [[Paragraph(str(cell), styles["Normal"]) for cell in
> row] for row in report_data]
> + table = Table(report_data, repeatRows=1, colWidths=[75,75])
> +
> + # format for table in the report file
> + table.setStyle(TableStyle([("INNERGRID", (0, 0), (-1, -1), 0.25,
> colors.black),
> + ("BOX", (0, 0), (-1, -1), 0.25,
> colors.black),
> + ("BACKGROUND",(0, 0), (len(fields) -
> 1,0), colors.silver),
> + ("VALIGN",(0, 0), (-1, -1), "MIDDLE")]))
> +
> + elements.append(table)
> + doc.build(elements, onFirstPage=add_page_number,
> onLaterPages=add_page_number)
> +
> # generate a report from run results
> def do_gen_report(conf, options):
> global quiet, verbose
> @@ -2058,7 +2098,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"]:
> + if fmt not in ["txt","html","pdf"]:
> error_out("Unsupported format '%s' specified" % fmt)
>
> if "--layout" in options:
> @@ -2073,6 +2113,11 @@ def do_gen_report(conf, options):
> #fields = ["test_name", "spec", "board", "timestamp", "tguid",
> "status"]
> #rfields = ["test_name", "spec", "board", "timestamp",
> "tguid", "tguid:measure", "tguid:unit", "tguid:status", "tguid:result"]
>
> + # create a directory to save report files
> + report_dir = "/fuego-rw/report/"
> + if not os.path.exists(report_dir):
> + os.makedirs(report_dir)
> +
> # get data for report
> header_data = get_report_header_data(run_list, run_map,
> header_fields)
> report_data = get_report_data(run_list, run_map, fields)
> @@ -2081,6 +2126,9 @@ def do_gen_report(conf, options):
> report = gen_text_report(header_data, report_data)
> if fmt=="html":
> report = gen_html_report(header_data, report_data)
> + if fmt=="pdf":
> + gen_pdf_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@toshiba-tsdv.com
> ==========================================================
> ======
>
>
> --
> This mail was scanned by BitDefender
> For more information please visit http://www.bitdefender.com
>
> _______________________________________________
> Fuego mailing list
> Fuego@lists.linuxfoundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/fuego
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Fuego] [PATCH 1/3] ftc: gen-report: Add pdf formatter
2018-03-07 23:04 ` Tim.Bird
@ 2018-03-08 2:48 ` Hoang Van Tuyen
2018-03-08 18:32 ` Tim.Bird
0 siblings, 1 reply; 4+ messages in thread
From: Hoang Van Tuyen @ 2018-03-08 2:48 UTC (permalink / raw)
To: Tim.Bird, fuego
[-- Attachment #1: Type: text/plain, Size: 4942 bytes --]
It has some difference between html and plain text format.
I re-send the patch as an attachment.
Best regards,
Tuyen
On 3/8/2018 6:04 AM, Tim.Bird@sony.com wrote:
> This patch also has wrapping issues.
> -- Tim
>
>> -----Original Message-----
>> From: fuego-bounces@lists.linuxfoundation.org [mailto:fuego-
>> bounces@lists.linuxfoundation.org] On Behalf Of Hoang Van Tuyen
>> Sent: Thursday, March 01, 2018 7:36 PM
>> To: fuego@lists.linuxfoundation.org
>> Subject: [Fuego] [PATCH 1/3] ftc: gen-report: Add pdf formatter
>>
>> Add a formatter for pdf report output. By default, the pdf
>> output file is stored in /fuego-rw/report with name report.pdf.
>>
>> It uses a reportlab python library for generating the report,
>> So, please make sure that the library is available in the system.
>>
>> Signed-off-by: Hoang Van Tuyen <tuyen.hoangvan@toshiba-tsdv.com>
>> ---
>> engine/scripts/ftc | 50
>> +++++++++++++++++++++++++++++++++++++++++++++++++-
>> 1 file changed, 49 insertions(+), 1 deletion(-)
>>
>> diff --git a/engine/scripts/ftc b/engine/scripts/ftc
>> index c6a0f3d..0b99f94 100755
>> --- a/engine/scripts/ftc
>> +++ b/engine/scripts/ftc
>> @@ -2037,6 +2037,46 @@ def gen_html_report(header_data, report_data):
>>
>> return report
>>
>> +# add page number for a pdf file
>> +def add_page_number(canvas, doc):
>> + from reportlab.lib.units import mm
>> +
>> + page_num = canvas.getPageNumber()
>> + text = "Page %s" % page_num
>> + canvas.drawRightString(200*mm, 20*mm, text)
>> +
>> +def gen_pdf_report(header_data, report_data, report_dir):
>> + from reportlab.lib import colors
>> + from reportlab.lib.pagesizes import A4
>> + from reportlab.lib.styles import getSampleStyleSheet
>> + from reportlab.platypus import SimpleDocTemplate, Table,
>> TableStyle, Paragraph
>> +
>> + # create a pdf file
>> + doc = SimpleDocTemplate(report_dir + "report.pdf", pagesize=A4)
>> + elements = []
>> +
>> + # generate header
>> + styles = getSampleStyleSheet()
>> + elements.append(Paragraph("Fuego Test Report\n", styles["Heading1"]))
>> + for field,val_str in header_data:
>> + elements.append(Paragraph("%s: %s\n" % (field, val_str),
>> styles["Normal"]))
>> +
>> + # generate lines for this report
>> + fields = report_data[0]
>> +
>> + # create the table with a header row in each page
>> + report_data = [[Paragraph(str(cell), styles["Normal"]) for cell in
>> row] for row in report_data]
>> + table = Table(report_data, repeatRows=1, colWidths=[75,75])
>> +
>> + # format for table in the report file
>> + table.setStyle(TableStyle([("INNERGRID", (0, 0), (-1, -1), 0.25,
>> colors.black),
>> + ("BOX", (0, 0), (-1, -1), 0.25,
>> colors.black),
>> + ("BACKGROUND",(0, 0), (len(fields) -
>> 1,0), colors.silver),
>> + ("VALIGN",(0, 0), (-1, -1), "MIDDLE")]))
>> +
>> + elements.append(table)
>> + doc.build(elements, onFirstPage=add_page_number,
>> onLaterPages=add_page_number)
>> +
>> # generate a report from run results
>> def do_gen_report(conf, options):
>> global quiet, verbose
>> @@ -2058,7 +2098,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"]:
>> + if fmt not in ["txt","html","pdf"]:
>> error_out("Unsupported format '%s' specified" % fmt)
>>
>> if "--layout" in options:
>> @@ -2073,6 +2113,11 @@ def do_gen_report(conf, options):
>> #fields = ["test_name", "spec", "board", "timestamp", "tguid",
>> "status"]
>> #rfields = ["test_name", "spec", "board", "timestamp",
>> "tguid", "tguid:measure", "tguid:unit", "tguid:status", "tguid:result"]
>>
>> + # create a directory to save report files
>> + report_dir = "/fuego-rw/report/"
>> + if not os.path.exists(report_dir):
>> + os.makedirs(report_dir)
>> +
>> # get data for report
>> header_data = get_report_header_data(run_list, run_map,
>> header_fields)
>> report_data = get_report_data(run_list, run_map, fields)
>> @@ -2081,6 +2126,9 @@ def do_gen_report(conf, options):
>> report = gen_text_report(header_data, report_data)
>> if fmt=="html":
>> report = gen_html_report(header_data, report_data)
>> + if fmt=="pdf":
>> + gen_pdf_report(header_data, report_data, report_dir)
>> + sys.exit(0)
>>
>> print report
>>
>> --
>> 2.1.4
>>
>>
>>
>> _______________________________________________
>> Fuego mailing list
>> Fuego@lists.linuxfoundation.org
>> https://lists.linuxfoundation.org/mailman/listinfo/fuego
_______________________________________________
Fuego mailing list
Fuego@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/fuego
[-- Attachment #2: 0001-ftc-gen-report-Add-pdf-formatter.patch --]
[-- Type: text/plain, Size: 3955 bytes --]
From ae8643f43b4469c02d9366e95a5def70aaf706ff Mon Sep 17 00:00:00 2001
From: Hoang Van Tuyen <tuyen.hoangvan@toshiba-tsdv.com>
Date: Thu, 1 Mar 2018 14:10:22 +0700
Subject: [PATCH 1/3] ftc: gen-report: Add pdf formatter
Add a formatter for pdf report output. By default, the pdf
output file is stored in /fuego-rw/report with name report.pdf.
It uses a reportlab python library for generating the report,
So, please make sure that the library is available in the system.
Signed-off-by: Hoang Van Tuyen <tuyen.hoangvan@toshiba-tsdv.com>
---
engine/scripts/ftc | 50 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 49 insertions(+), 1 deletion(-)
diff --git a/engine/scripts/ftc b/engine/scripts/ftc
index c6a0f3d..0b99f94 100755
--- a/engine/scripts/ftc
+++ b/engine/scripts/ftc
@@ -2037,6 +2037,46 @@ def gen_html_report(header_data, report_data):
return report
+# add page number for a pdf file
+def add_page_number(canvas, doc):
+ from reportlab.lib.units import mm
+
+ page_num = canvas.getPageNumber()
+ text = "Page %s" % page_num
+ canvas.drawRightString(200*mm, 20*mm, text)
+
+def gen_pdf_report(header_data, report_data, report_dir):
+ from reportlab.lib import colors
+ from reportlab.lib.pagesizes import A4
+ from reportlab.lib.styles import getSampleStyleSheet
+ from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Paragraph
+
+ # create a pdf file
+ doc = SimpleDocTemplate(report_dir + "report.pdf", pagesize=A4)
+ elements = []
+
+ # generate header
+ styles = getSampleStyleSheet()
+ elements.append(Paragraph("Fuego Test Report\n", styles["Heading1"]))
+ for field,val_str in header_data:
+ elements.append(Paragraph("%s: %s\n" % (field, val_str), styles["Normal"]))
+
+ # generate lines for this report
+ fields = report_data[0]
+
+ # create the table with a header row in each page
+ report_data = [[Paragraph(str(cell), styles["Normal"]) for cell in row] for row in report_data]
+ table = Table(report_data, repeatRows=1, colWidths=[75,75])
+
+ # format for table in the report file
+ table.setStyle(TableStyle([("INNERGRID", (0, 0), (-1, -1), 0.25, colors.black),
+ ("BOX", (0, 0), (-1, -1), 0.25, colors.black),
+ ("BACKGROUND",(0, 0), (len(fields) - 1,0), colors.silver),
+ ("VALIGN",(0, 0), (-1, -1), "MIDDLE")]))
+
+ elements.append(table)
+ doc.build(elements, onFirstPage=add_page_number, onLaterPages=add_page_number)
+
# generate a report from run results
def do_gen_report(conf, options):
global quiet, verbose
@@ -2058,7 +2098,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"]:
+ if fmt not in ["txt","html","pdf"]:
error_out("Unsupported format '%s' specified" % fmt)
if "--layout" in options:
@@ -2073,6 +2113,11 @@ def do_gen_report(conf, options):
#fields = ["test_name", "spec", "board", "timestamp", "tguid", "status"]
#rfields = ["test_name", "spec", "board", "timestamp", "tguid", "tguid:measure", "tguid:unit", "tguid:status", "tguid:result"]
+ # create a directory to save report files
+ report_dir = "/fuego-rw/report/"
+ if not os.path.exists(report_dir):
+ os.makedirs(report_dir)
+
# get data for report
header_data = get_report_header_data(run_list, run_map, header_fields)
report_data = get_report_data(run_list, run_map, fields)
@@ -2081,6 +2126,9 @@ def do_gen_report(conf, options):
report = gen_text_report(header_data, report_data)
if fmt=="html":
report = gen_html_report(header_data, report_data)
+ if fmt=="pdf":
+ gen_pdf_report(header_data, report_data, report_dir)
+ sys.exit(0)
print report
--
2.1.4
[-- Attachment #3: Bitdefender.txt --]
[-- Type: text/plain, Size: 102 bytes --]
--
This mail was scanned by BitDefender
For more information please visit http://www.bitdefender.com
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Fuego] [PATCH 1/3] ftc: gen-report: Add pdf formatter
2018-03-08 2:48 ` Hoang Van Tuyen
@ 2018-03-08 18:32 ` Tim.Bird
0 siblings, 0 replies; 4+ messages in thread
From: Tim.Bird @ 2018-03-08 18:32 UTC (permalink / raw)
To: tuyen.hoangvan, fuego
Comments inline below.
> -----Original Message-----
> From: fuego-bounces@lists.linuxfoundation.org [mailto:fuego-
> bounces@lists.linuxfoundation.org] On Behalf Of Hoang Van Tuyen
> Sent: Wednesday, March 07, 2018 6:48 PM
> To: Bird, Timothy <Tim.Bird@sony.com>; fuego@lists.linuxfoundation.org
> Subject: Re: [Fuego] [PATCH 1/3] ftc: gen-report: Add pdf formatter
>
> It has some difference between html and plain text format.
>
> I re-send the patch as an attachment.
>
> Best regards,
>
> Tuyen
>
>
> On 3/8/2018 6:04 AM, Tim.Bird@sony.com wrote:
> > This patch also has wrapping issues.
> > -- Tim
> >
> >> -----Original Message-----
> >> From: fuego-bounces@lists.linuxfoundation.org [mailto:fuego-
> >> bounces@lists.linuxfoundation.org] On Behalf Of Hoang Van Tuyen
> >> Sent: Thursday, March 01, 2018 7:36 PM
> >> To: fuego@lists.linuxfoundation.org
> >> Subject: [Fuego] [PATCH 1/3] ftc: gen-report: Add pdf formatter
> >>
> >> Add a formatter for pdf report output. By default, the pdf
> >> output file is stored in /fuego-rw/report with name report.pdf.
> >>
> >> It uses a reportlab python library for generating the report,
> >> So, please make sure that the library is available in the system.
> >>
> >> Signed-off-by: Hoang Van Tuyen <tuyen.hoangvan@toshiba-tsdv.com>
> >> ---
> >> engine/scripts/ftc | 50
> >> +++++++++++++++++++++++++++++++++++++++++++++++++-
> >> 1 file changed, 49 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/engine/scripts/ftc b/engine/scripts/ftc
> >> index c6a0f3d..0b99f94 100755
> >> --- a/engine/scripts/ftc
> >> +++ b/engine/scripts/ftc
> >> @@ -2037,6 +2037,46 @@ def gen_html_report(header_data,
> report_data):
> >>
> >> return report
> >>
> >> +# add page number for a pdf file
> >> +def add_page_number(canvas, doc):
> >> + from reportlab.lib.units import mm
> >> +
> >> + page_num = canvas.getPageNumber()
> >> + text = "Page %s" % page_num
> >> + canvas.drawRightString(200*mm, 20*mm, text)
> >> +
> >> +def gen_pdf_report(header_data, report_data, report_dir):
> >> + from reportlab.lib import colors
> >> + from reportlab.lib.pagesizes import A4
> >> + from reportlab.lib.styles import getSampleStyleSheet
> >> + from reportlab.platypus import SimpleDocTemplate, Table,
> >> TableStyle, Paragraph
> >> +
> >> + # create a pdf file
> >> + doc = SimpleDocTemplate(report_dir + "report.pdf", pagesize=A4)
Eventually we'll want to be able to specify the report filename. Using
the same one every time means it's subject to getting overwritten
every time we generate a report. See below for more discussion about
a '-o' option.
> >> + elements = []
> >> +
> >> + # generate header
> >> + styles = getSampleStyleSheet()
> >> + elements.append(Paragraph("Fuego Test Report\n",
> styles["Heading1"]))
> >> + for field,val_str in header_data:
> >> + elements.append(Paragraph("%s: %s\n" % (field, val_str),
> >> styles["Normal"]))
> >> +
> >> + # generate lines for this report
> >> + fields = report_data[0]
> >> +
> >> + # create the table with a header row in each page
> >> + report_data = [[Paragraph(str(cell), styles["Normal"]) for cell in
> >> row] for row in report_data]
> >> + table = Table(report_data, repeatRows=1, colWidths=[75,75])
> >> +
> >> + # format for table in the report file
> >> + table.setStyle(TableStyle([("INNERGRID", (0, 0), (-1, -1), 0.25,
> >> colors.black),
> >> + ("BOX", (0, 0), (-1, -1), 0.25,
> >> colors.black),
> >> + ("BACKGROUND",(0, 0), (len(fields) -
> >> 1,0), colors.silver),
> >> + ("VALIGN",(0, 0), (-1, -1), "MIDDLE")]))
> >> +
> >> + elements.append(table)
> >> + doc.build(elements, onFirstPage=add_page_number,
> >> onLaterPages=add_page_number)
> >> +
> >> # generate a report from run results
> >> def do_gen_report(conf, options):
> >> global quiet, verbose
> >> @@ -2058,7 +2098,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"]:
> >> + if fmt not in ["txt","html","pdf"]:
> >> error_out("Unsupported format '%s' specified" % fmt)
> >>
> >> if "--layout" in options:
> >> @@ -2073,6 +2113,11 @@ def do_gen_report(conf, options):
> >> #fields = ["test_name", "spec", "board", "timestamp", "tguid",
> >> "status"]
> >> #rfields = ["test_name", "spec", "board", "timestamp",
> >> "tguid", "tguid:measure", "tguid:unit", "tguid:status", "tguid:result"]
> >>
> >> + # create a directory to save report files
> >> + report_dir = "/fuego-rw/report/"
I prefer to use the default report_dir of '/fuego-rw/reports'
(with a trailing 's'). I changed the patch. Let me know if you disagree.
It's nice to have the report show up in /fuego-rw, so they can
be seen from the host machine, and viewed and printed
without further fuss.
As a note, eventually we'd like to be able to specify the output
path on the ftc command line, using a '-o' option. That would override
the report_dir setting here (as well as make it necessary to
pass in the full final filename).
I'm a little worried that the specification of output location is a bit
different for this format than for other formats. This one writes
a file, and the others (txt and html) write to stdout. We may have
to rationalize that later when we add the '-o' command line option
to 'ftc gen-report'.
This is good for now, thought.
> >> + if not os.path.exists(report_dir):
> >> + os.makedirs(report_dir)
> >> +
> >> # get data for report
> >> header_data = get_report_header_data(run_list, run_map,
> >> header_fields)
> >> report_data = get_report_data(run_list, run_map, fields)
> >> @@ -2081,6 +2126,9 @@ def do_gen_report(conf, options):
> >> report = gen_text_report(header_data, report_data)
> >> if fmt=="html":
> >> report = gen_html_report(header_data, report_data)
> >> + if fmt=="pdf":
> >> + gen_pdf_report(header_data, report_data, report_dir)
> >> + sys.exit(0)
> >>
> >> print report
> >>
> >> --
> >> 2.1.4
Applied. Thanks.
-- Tim
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-03-08 18:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-02 3:36 [Fuego] [PATCH 1/3] ftc: gen-report: Add pdf formatter Hoang Van Tuyen
2018-03-07 23:04 ` Tim.Bird
2018-03-08 2:48 ` Hoang Van Tuyen
2018-03-08 18:32 ` Tim.Bird
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.