-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
a report plugin.Anyone interested? #723
Comments
` ` add route to webserveradd data when request_stats callingappend these code to function request_stats |
perhaps make this into a PR? |
ok.i will do it. |
Closing in favor of PR |
`"""
pdf report for Locust Test,
提供给webui调用,flask 里面的 路径 /pdfreport 会调用生成pdf,
此文件的 getpdfreport 函数生成一个pdf文件
传回pdf的文件名
"""
def getpdfreport(allreport, curpath):
"""
:param allreport: json数据
:param curpath: 当前路径,用于 logo 获取和字体获取
:return:生成的pdf文件路径
"""
import pathlib
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.pdfbase import pdfmetrics
import time
from reportlab.platypus import Paragraph
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib.pagesizes import A4
from reportlab.platypus import SimpleDocTemplate
from reportlab.platypus import PageBreak
pdfmetrics.registerFont(TTFont('Songti', pathlib.PurePath(curpath) / 'static' / 'Songti.ttc', subfontIndex=1))
page_height = A4[1]
page_width = A4[0]
# 测试的开始与结束时间
st = allreport['reports'][0]['time']
et = allreport['reports'][-1]['time']
filename = pathlib.PurePath(curpath) / 'pdfreports' / ('locustreport_' + str(time.time()) + '.pdf')
# 报告数据,一个数组,存放的是 被打印对象
reports = [PageBreak()]
if name == 'main':
import json
`
The text was updated successfully, but these errors were encountered: