diff options
author | Yiting.Li <liyiting@huawei.com> | 2016-01-19 14:39:31 +0800 |
---|---|---|
committer | Yiting.Li <liyiting@huawei.com> | 2016-01-19 14:39:31 +0800 |
commit | 5b4f794932cb9b28ec679e6dd88e6febb2a5db7b (patch) | |
tree | d7b2615275a93ef1c2c878a0732b687832267174 /vstf/vstf/controller/reporters/reporter.py | |
parent | 827a986f4abc404dc803380a25d5e9ade7448f67 (diff) |
JIRA: BOTTLENECKS-29
add the performance test framework
add the copyright on the code.
Change-Id: I6ec9eefe65bf07c2dd6c636d1b90b64da303952e
Signed-off-by: Yiting.Li <liyiting@huawei.com>
Diffstat (limited to 'vstf/vstf/controller/reporters/reporter.py')
-rwxr-xr-x | vstf/vstf/controller/reporters/reporter.py | 58 |
1 files changed, 36 insertions, 22 deletions
diff --git a/vstf/vstf/controller/reporters/reporter.py b/vstf/vstf/controller/reporters/reporter.py index 1c256c61..e77ae349 100755 --- a/vstf/vstf/controller/reporters/reporter.py +++ b/vstf/vstf/controller/reporters/reporter.py @@ -1,21 +1,28 @@ -#!/usr/bin/python -# -*- coding: utf8 -*- -# author: wly -# date: 2015-05-29 -# see license for license details +############################################################################## +# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + import os import argparse import logging import time -from vstf.controller.reporters.report.pdf.pdfcreator import PdfvSwitchCreator -from vstf.controller.reporters.report.html.htmlcreator import HtmlvSwitchCreator -from vstf.controller.reporters.report.data_factory import CommonData, TaskData, ScenarioData, HistoryData +from vstf.controller.reporters.report.provider.html_provider import HtmlProvider +from vstf.controller.reporters.report.provider.pdf_provider import PdfProvider +from vstf.controller.settings.template_settings import TemplateSettings +from vstf.controller.reporters.report.data_factory import TaskData +from vstf.controller.reporters.report.html.htmlcreator import HtmlCreator +from vstf.controller.reporters.report.pdf.pdfcreator import PdfCreator from vstf.controller.database.dbinterface import DbManage from vstf.controller.settings.mail_settings import MailSettings from vstf.controller.reporters.mail.sendmail import SendMail from vstf.controller.settings.html_settings import HtmlSettings -from vstf.controller.reporters.report.provider.html_provider import StyleProvider +from vstf.controller.reporters.report.candy_generator import CandyGenerator import vstf.common.constants as cst @@ -31,37 +38,44 @@ class Report(object): """ self._dbase = dbase self._rpath = "." + self._mail_settings = MailSettings() if os.path.exists(rpath): self._rpath = rpath def create_pdf(self, taskid): - common_data = CommonData(taskid, self._dbase) - scenario_list = common_data.get_scenariolist() - history_data = HistoryData(taskid, self._dbase) + task = TaskData(taskid, self._dbase) + scenario_list = task.common.get_scenariolist() + creator = CandyGenerator(task) attach_list = [] for scenario in scenario_list: - out_file = os.path.join(self._rpath, "vstf_report_%s_%s.pdf" % (scenario, time.strftime(cst.TIME_STR))) + out_file = os.path.join(self._rpath, "vstf_report_%s_%s.pdf" % (scenario, time.strftime(cst.TIME_FORMAT3))) LOG.info(out_file) - scenario_data = ScenarioData(taskid, self._dbase, scenario) - pdf = PdfvSwitchCreator(out_file, common_data, scenario_data, history_data) - if pdf: - pdf.create() - attach_list.append(out_file) + creator.create(scenario) + info = TemplateSettings() + provider = PdfProvider(info.settings) + reporter = PdfCreator(provider) + reporter.create(out_file) + attach_list.append(out_file) + if attach_list: self._mail_settings.mset_attach(attach_list) def create_html(self, taskid): - task_data = TaskData(taskid, self._dbase) + task = TaskData(taskid, self._dbase) + + creator = CandyGenerator(task) + creator.create_all() html_settings = HtmlSettings() + info = TemplateSettings() LOG.info(html_settings.settings) - provider = StyleProvider(html_settings.settings) + provider = HtmlProvider(info.settings, html_settings.settings) out_file = os.path.join(self._rpath, "mail.html") LOG.info(out_file) - html = HtmlvSwitchCreator(task_data, provider, out_file) - content = html.create() + html = HtmlCreator(provider) + content = html.create(out_file) self._mail_settings.mset_subtype('html') self._mail_settings.mset_content(content) |