diff options
Diffstat (limited to 'vstf/vstf/controller/reporters/report/pdf')
6 files changed, 176 insertions, 484 deletions
diff --git a/vstf/vstf/controller/reporters/report/pdf/__init__.py b/vstf/vstf/controller/reporters/report/pdf/__init__.py index 89dcd4e2..df7d24d0 100755 --- a/vstf/vstf/controller/reporters/report/pdf/__init__.py +++ b/vstf/vstf/controller/reporters/report/pdf/__init__.py @@ -1,14 +1,9 @@ -# Copyright Huawei Technologies Co., Ltd. 1998-2015. -# All Rights Reserved. +############################################################################## +# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others. # -# Licensed under the Apache License, Version 2.0 (the License); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an AS IS BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. +# 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 +############################################################################## + diff --git a/vstf/vstf/controller/reporters/report/pdf/element.py b/vstf/vstf/controller/reporters/report/pdf/element.py index 2528f2c5..78d1c59b 100755 --- a/vstf/vstf/controller/reporters/report/pdf/element.py +++ b/vstf/vstf/controller/reporters/report/pdf/element.py @@ -1,8 +1,12 @@ -#!/usr/bin/python -# -*- coding: utf8 -*- -# author: wly -# date: 2015-05-04 -# 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 +############################################################################## + __version__ = ''' ''' __doc__ = """ it contains the base element for pdf diff --git a/vstf/vstf/controller/reporters/report/pdf/pdfcreator.py b/vstf/vstf/controller/reporters/report/pdf/pdfcreator.py index 50b3bc65..4f7bd2a8 100755 --- a/vstf/vstf/controller/reporters/report/pdf/pdfcreator.py +++ b/vstf/vstf/controller/reporters/report/pdf/pdfcreator.py @@ -1,446 +1,129 @@ -#!/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 +############################################################################## + __version__ = ''' ''' -import os -from vstf.controller.reporters.report.pdf.styles import TemplateStyle from vstf.controller.reporters.report.pdf.pdftemplate import PdfVswitch -from vstf.controller.reporters.report.pdf.story import TitleStory, SpaceStory, ImageStory, LineChartStory, \ - LinePlotStory, uTableStory, Story, TableOfContentsStory, PageBreakStory, ParagraphStory, BarChartStory, cTableStory -from vstf.controller.reporters.report.data_factory import CommonData, ScenarioData, HistoryData -from vstf.controller.database.dbinterface import DbManage -import vstf.controller - +from vstf.controller.reporters.report.pdf.story import TitleStory, SpaceStory, ImageStory, TableStory, \ + LinePlotStory, Story, TableOfContentsStory, PageBreakStory, ParagraphStory, BarChartStory +import vstf.common.candy_text as candy +from vstf.controller.reporters.report.provider.pdf_provider import PdfProvider +from vstf.controller.settings.template_settings import TemplateSettings -class LetterOrder(object): - def __init__(self): - self.lettertable = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - self._cur = 0 - self._len = len(self.lettertable) - - def get(self): - return self.lettertable[self._cur] - - def pre(self): - self._cur = (self._cur + self._len - 1) % self._len +import os +import logging - def next(self): - self._cur = (self._cur + 1) % self._len +LOG = logging.getLogger(__name__) -class PdfBase(object): - def __init__(self): - self._case = '' - self._ofile = '' - self._title = [] +class PdfCreator(object): + def __init__(self, provider): + self._provider = provider self._story = [] - self._rootdir = os.path.dirname(vstf.controller.__file__) + '/' self._pdf = None def create_pdf(self): - style = TemplateStyle(name='default') - title = self._title - logo = [self._rootdir + "res/logo.jpg"] - header = [''] - footer = [""] - note = ['', ''] - output = [self._ofile] - self._pdf = PdfFrameLoss(style, title, logo, header, footer, output, note) + theme = self._provider.get_theme + self._pdf = PdfVswitch(theme["title"], + theme["logo"], + theme["header"], + theme["footer"], + theme["note"], + theme["style"]) - def save_pdf(self): - self._pdf.generate(self._story) + def save_pdf(self, ofile): + self._pdf.generate(self._story, ofile) def add_coverpage(self): story = Story() story = PageBreakStory(story) self._story += story.storylist - def create_story(self): - raise NotImplementedError("abstract PdfBase") - - def create(self): - self.create_pdf() - self.create_story() - self.save_pdf() - - -class PdfvSwitchCreator(PdfBase): - def __init__(self, ofile, common_data, scenario_data, history_data): - PdfBase.__init__(self) - self._common = common_data - self._result = scenario_data - self._history = history_data - self._ofile = ofile - self._chapterid = 0 - self._appendixid = LetterOrder() - - def create_pdf(self): - style = TemplateStyle(name='default') - title = self._result.get_covertitle() - logo = [self._rootdir + "res/logo.jpg"] - header = [''] - footer = [""] - note = ['', ''] - output = [self._ofile] - self._pdf = PdfVswitch(style, title, logo, header, footer, output, note) - - def get_chapterid(self): - self._chapterid = self._chapterid + 1 - return self._chapterid + def add_contents(self): + if self._provider.ifcontents: + story = Story() + story = TableOfContentsStory(story) + self._story += story.storylist def create_story(self): self.add_coverpage() - self.add_table_of_contents() - # self.add_contact() - # self.add_overview() - self.add_scenario() - # self.add_info() - # self.add_appendix() - self.add_historys() - - def add_info(self): - self.add_systeminfo() - self.add_gitinfo() - self.add_profile_parameters() - self.add_testing_options() - - def add_contact(self): - story = Story() - story = SpaceStory(story) - title = ["", "", "", "Reporter"] - body = self._common.get_contact() - story = TitleStory(story, data=title, style=7) - story = ParagraphStory(story, data=body) - self._story += story.storylist - - def add_table_of_contents(self): - story = Story() - story = TableOfContentsStory(story) - self._story += story.storylist - - def add_overview(self): - story = Story() - story = PageBreakStory(story) - - chapterid = self.get_chapterid() - title = ["%d.Overview" % (chapterid)] - body = [""] - story = TitleStory(story, data=title, style=1) - story = ParagraphStory(story, data=body) - - sectionid = 1 - title = ["%d.%d Components under Test" % (chapterid, sectionid)] - body = self._common.get_components() - story = TitleStory(story, data=title, style=2) - story = ParagraphStory(story, data=body) - - sectionid = sectionid + 1 - title = ["%d.%d Test" % (chapterid, sectionid)] - body = self._result.get_test() - story = TitleStory(story, data=title, style=2) - story = ParagraphStory(story, data=body) - - sectionid = sectionid + 1 - title = ["%d.%d Configuration" % (chapterid, sectionid)] - story = TitleStory(story, data=title, style=2) - - title = ["Software"] - body = self._common.get_software() - story = TitleStory(story, data=title, style=6) - story = ParagraphStory(story, data=body) - - title = ["Hardware"] - body = self._common.get_hardware() - story = TitleStory(story, data=title, style=6) - story = ParagraphStory(story, data=body) - self._story += story.storylist - - def add_scenario(self): - case_list = self._result.get_caselist() - for case in case_list: - self.add_case(case) - - def add_case(self, case): - story = Story() - chapterid = self.get_chapterid() - - title = ["%d. Case : %s (%s)" % (chapterid, case, self._common.get_casename(case))] - - tools = self._result.get_test_tools(case) - pic = self._common.get_casefigure(case, tools) - print pic - - story = TitleStory(story, data=title, style=1) - story = SpaceStory(story) - story = ImageStory(story, data=[self._rootdir + pic]) - story = SpaceStory(story) - - sectionid = 1 - story = self.add_summary(story, chapterid, sectionid, case) - story = SpaceStory(story) - - if self._result.is_throughput_start(case): - sectionid = sectionid + 1 - story = self.add_throughput_result(story, chapterid, sectionid, case) - - if self._result.is_frameloss_start(case): - sectionid = sectionid + 1 - story = self.add_frameloss_result(story, chapterid, sectionid, case) - - if self._result.is_latency_start(case): - sectionid = sectionid + 1 - story = self.add_latency_result(story, chapterid, sectionid, case) - - story = SpaceStory(story) - story = SpaceStory(story) - self._story += story.storylist - - def add_summary(self, story, chapterid, sectionid, case): - title = ["%d.%d Summary" % (chapterid, sectionid)] - story = TitleStory(story, data=title, style=2) - provider_list = ["fastlink", "rdp", "l2switch"] - provider_dict = {"fastlink": "Fast Link", "l2switch": "L2Switch", "rdp": "Kernel RDP"} - unitid = 1 - case_name = self._common.get_casename(case) - for provider in provider_list: - if self._result.is_provider_start(case, provider): - title = ["%d.%d.%d %s (%s_%s)" % ( - chapterid, sectionid, unitid, provider_dict[provider], case_name, provider)] - unitid = unitid + 1 - story = TitleStory(story, data=title, style=6) - test_types = ["throughput", "frameloss"] - for test_type in test_types: - if self._result.is_type_provider_start(case, provider, test_type): - story = self.add_summary_type(story, case, provider, test_type) - return story - - def add_summary_type(self, story, case, provider, test_type): - bar_list = [test_type, "latency"] - for item in bar_list: - bar_data = self._result.get_bardata(case, provider, item) - story = SpaceStory(story) - story = BarChartStory(story, data=bar_data) - - table_content = self._result.get_summary_tabledata(case, provider, test_type) - story = SpaceStory(story) - story = cTableStory(story, data=table_content, style=3) - story = SpaceStory(story) - return story + self.add_contents() + self.add_context() - def add_throughput_result(self, story, chapterid, sectionid, case): - title = ["%d.%d Throughput " % (chapterid, sectionid)] - story = TitleStory(story, data=title, style=2) - unitid = 1 - title = ["%d.%d.%d Summary" % (chapterid, sectionid, unitid)] - story = TitleStory(story, data=title, style=6) - - test_type = "throughput" - unit = 'RX Frame Rate' - chart_data = self._result.get_frameloss_chartdata(case, test_type) - table_data = self._result.get_frameloss_tabledata(case, test_type) - title = [unit + ' (%)'] - story = TitleStory(story, data=title, style=6) - # story = SpaceStory(story) - # story = LinePlotStory(story, data=chart_data) - story = SpaceStory(story) - story = uTableStory(story, data=table_data) - story = SpaceStory(story) - - unit = 'Frame Loss Rate' - title = [unit + ' (Mpps)'] - - chart_data = self._result.get_framerate_chartdata(case, test_type) - table_data = self._result.get_framerate_tabledata(case, test_type) - story = TitleStory(story, data=title, style=6) - story = SpaceStory(story) - story = LinePlotStory(story, data=chart_data) - story = SpaceStory(story) - story = uTableStory(story, data=table_data) - story = SpaceStory(story) - return story - - def add_frameloss_result(self, story, chapterid, sectionid, case): - title = ["%d.%d Frame Loss Rate " % (chapterid, sectionid)] - story = TitleStory(story, data=title, style=2) - unitid = 1 - title = ["%d.%d.%d Summary" % (chapterid, sectionid, unitid)] - story = TitleStory(story, data=title, style=6) - - test_type = "frameloss" - unit = 'RX Frame Rate' - chart_data = self._result.get_frameloss_chartdata(case, test_type) - table_data = self._result.get_frameloss_tabledata(case, test_type) - title = [unit + ' (%)'] - story = TitleStory(story, data=title, style=6) - # story = SpaceStory(story) - # story = LineChartStory(story, data=chart_data) - story = SpaceStory(story) - story = uTableStory(story, data=table_data) - story = SpaceStory(story) - - unit = 'Frame Loss Rate' - title = [unit + ' (Mpps)'] - - chart_data = self._result.get_framerate_chartdata(case, test_type) - table_data = self._result.get_framerate_tabledata(case, test_type) - story = TitleStory(story, data=title, style=6) - story = SpaceStory(story) - story = LineChartStory(story, data=chart_data) - story = SpaceStory(story) - story = uTableStory(story, data=table_data) - story = SpaceStory(story) - return story - - def add_latency_result(self, story, chapterid, sectionid, case): - title = ["%d.%d Latency " % (chapterid, sectionid)] - story = TitleStory(story, data=title, style=2) - unitid = 1 - title = ["%d.%d.%d Summary" % (chapterid, sectionid, unitid)] - story = TitleStory(story, data=title, style=6) - - unit = 'Average Latency' - title = [unit + ' (uSec)'] - # chart_data = self._result.get_latency_chartdata(case) - bar_data = self._result.get_latency_bardata(case) - table_data = self._result.get_latency_tabledata(case) - story = TitleStory(story, data=title, style=6) - story = SpaceStory(story) - # story = LineChartStory(story, data=chart_data) - story = BarChartStory(story, data=bar_data) - - story = SpaceStory(story) - story = uTableStory(story, data=table_data) - story = SpaceStory(story) - return story - - def add_systeminfo(self): - story = Story() - chapterid = self.get_chapterid() - story = SpaceStory(story) - title = ["%d. System Information " % (chapterid)] - story = PageBreakStory(story) - story = TitleStory(story, data=title, style=1) - table_content = self._common.get_systeminfo_tabledata() - story = SpaceStory(story) - story = cTableStory(story, data=table_content, style=0) - story = SpaceStory(story) - self._story += story.storylist - - def add_gitinfo(self): - story = Story() - chapterid = self.get_chapterid() - title = ["%d. Git Repository Information " % (chapterid)] - story = TitleStory(story, data=title, style=1) - - table_content = self._common.get_gitinfo_tabledata() - if table_content: - story = SpaceStory(story) - story = cTableStory(story, data=table_content, style=5) - story = SpaceStory(story) - self._story += story.storylist - - def add_testing_options(self): - story = Story() - chapterid = self.get_chapterid() - story = SpaceStory(story) - title = ["%d. Testing Options" % (chapterid)] - - story = TitleStory(story, data=title, style=1) - table_content = self._common.get_testingoptions_tabledata() - story = SpaceStory(story) - story = cTableStory(story, data=table_content, style=1) - story = SpaceStory(story) - self._story += story.storylist - - def add_profile_parameters(self): - story = Story() - chapterid = self.get_chapterid() - story = PageBreakStory(story) - title = ["%d. " % (chapterid)] - story = TitleStory(story, data=title, style=1) - table_content = self._common.get_profileparameters_tabledData() - story = SpaceStory(story) - story = cTableStory(story, data=table_content, style=2) - story = SpaceStory(story) - self._story += story.storylist - - def add_appendix(self): - story = Story() - story = PageBreakStory(story) - - title = ["<b>Appendix %s: vSwitching Testing Methodology</b>" % (self._appendixid.get())] - self._appendixid.next() - story = TitleStory(story, data=title, style=1) - filename = "res/Traffic-types.jpg" - story = SpaceStory(story) - story = ImageStory(story, data=[self._rootdir + filename]) - # story = SpaceStory(story) - - title = ["Traffic Patterns: "] - story = TitleStory(story, data=title, style=6) - - body = [ - "<b>Ti</b> - South North Traffic", - "<b>Tu</b> - East Eest Traffic", - "<b>Tn</b> - Physical host or VM loop back", - "<b>Tnv</b> - Virtual Machine loop back", - ] - story = ParagraphStory(story, data=body) - - title = ["<b>Performance Testing Coverage </b> (version 0.1):"] - story = TitleStory(story, data=title, style=6) - - table_content = self._common.get_introduct_tabledata() - story = SpaceStory(story) - story = cTableStory(story, data=table_content, style=4) - self._story += story.storylist - - def add_historys(self): - case_list = self._result.get_caselist() - for case in case_list: - history = self._history.get_history_info(case) - if history: - self.add_history(case, history) - - def add_history(self, case, history): - story = Story() - story = PageBreakStory(story) - - title = ["<b>Appendix %s : %s History Records</b>" % (self._appendixid.get(), case)] - story = TitleStory(story, data=title, style=1) - - for i in range(len(history)): - title = ["%s.%s %s" % (self._appendixid.get(), i, history[i]["title"])] - story = TitleStory(story, data=title, style=2) - - section = history[i]["data"] - for unit in section: - title = [unit['title']] - story = TitleStory(story, data=title, style=6) - content = unit['data'] - story = uTableStory(story, data=content) - - self._appendixid.next() - self._story += story.storylist + def create(self, ofile): + self.create_pdf() + self.create_story() + self.save_pdf(ofile) + + def add_context(self): + context = self._provider.get_context + self._story += self._raw_context(context) + + def _raw_context(self, context, ci=0, si=0, ui=0, level=-1): + _story = [] + for key, value in sorted(context.items()): + LOG.info(key) + LOG.info(value) + _sn, _node, _style = candy.text2tuple(key) + if _node in candy.dom: + if _node == candy.chapter: + ci = _style + elif _node == candy.section: + si = _style + else: + ui = _style + _story += self._raw_context(value, ci, si, ui, level + 1) + + else: + story = Story() + LOG.info("node: %s %s" % (_node, candy.title)) + if _node == candy.title: + assert value + if level in range(len(candy.dom)): + if level == 0: + value[0] = "Chapter %s %s" % (ci, value[0]) + story = PageBreakStory(story) + elif level == 1: + value[0] = "%s.%s %s" % (ci, si, value[0]) + else: + value[0] = "%s.%s.%s %s" % (ci, si, ui, value[0]) + LOG.info(value) + story = TitleStory(story, data=value, style=_style) + elif _node == candy.table: + story = TableStory(story, data=value, style=_style) + elif _node == candy.figure: + story = ImageStory(story, data=value, style=_style) + elif _node == candy.paragraph: + story = ParagraphStory(story, data=value, style=_style) + elif _node == candy.plot: + story = LinePlotStory(story, data=value, style=_style) + elif _node == candy.chart: + story = BarChartStory(story, data=value, style=_style) + elif _node == candy.space: + assert isinstance(value, int) + for i in range(value): + story = SpaceStory(story) + _story += story.storylist + return _story def main(): - dbase = DbManage() - taskid = dbase.get_last_taskid() - common_data = CommonData(taskid, dbase) - scenario_list = common_data.get_scenariolist() - history_data = HistoryData(taskid, dbase) - for scenario in scenario_list: - out_file = "vstf_report_%s.pdf" % (scenario) - scenario_data = ScenarioData(taskid, dbase, scenario) - reporter = PdfvSwitchCreator(out_file, common_data, scenario_data, history_data) - if reporter: - reporter.create() + from vstf.common.log import setup_logging + setup_logging(level=logging.DEBUG, log_file="/var/log/pdf-creator.log", clevel=logging.INFO) + + out_file = "vstf_report.pdf" + info = TemplateSettings() + provider = PdfProvider(info.settings) + reporter = PdfCreator(provider) + reporter.create(out_file) if __name__ == '__main__': main() diff --git a/vstf/vstf/controller/reporters/report/pdf/pdftemplate.py b/vstf/vstf/controller/reporters/report/pdf/pdftemplate.py index 819a5c57..69c65401 100755 --- a/vstf/vstf/controller/reporters/report/pdf/pdftemplate.py +++ b/vstf/vstf/controller/reporters/report/pdf/pdftemplate.py @@ -1,13 +1,21 @@ -#!/usr/bin/python -# -*- coding: utf8 -*- +############################################################################## +# 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 time from reportlab.platypus.doctemplate import SimpleDocTemplate from reportlab.platypus import PageBreak from vstf.controller.reporters.report.pdf.styles import TemplateStyle, ps_head_lv1, ps_head_lv2, ps_head_lv3 +import vstf.common.constants as cst -class MyDocTemplate(SimpleDocTemplate): +class BaseDocTemplate(SimpleDocTemplate): def __init__(self, filename, **kw): self.allowSplitting = 0 SimpleDocTemplate.__init__(self, filename, **kw) @@ -25,17 +33,16 @@ class MyDocTemplate(SimpleDocTemplate): self.notify('TOCEntry', (2, text, self.page - 1)) -class PdfTemplate: - def __init__(self, style, title, logo, header, footer, output, note=None): - self._style = style +class PdfTemplate(object): + def __init__(self, title, logo, header, footer, note=[], style="default"): + self._style = TemplateStyle(name=style) self._title = title self._logo = logo[0] - self._header = header[0] + #self._header = header[0] self._footer = footer - self._output = output[0] self._note = note - info = " Generated on %s " % time.strftime('%Y/%m/%d %H:%M:%S', time.localtime()) - self._note[0] += info + info = " Generated on %s " % time.strftime(cst.TIME_FORMAT2, time.localtime()) + self._note += [info] def myFirstPage(self, canvas, doc): raise NotImplementedError("abstract StoryDecorator") @@ -43,9 +50,9 @@ class PdfTemplate: def myLaterPages(self, canvas, doc): raise NotImplementedError("abstract StoryDecorator") - def generate(self, story): + def generate(self, story, output): sizes = (self._style.page_wight, self._style.page_height) - doc = MyDocTemplate(self._output, pagesize=sizes) + doc = BaseDocTemplate(output, pagesize=sizes) # doc.build(story, onFirstPage=self.myFirstPage, onLaterPages=self.myLaterPages) doc.multiBuild(story, onFirstPage=self.myFirstPage, onLaterPages=self.myLaterPages) diff --git a/vstf/vstf/controller/reporters/report/pdf/story.py b/vstf/vstf/controller/reporters/report/pdf/story.py index 3e56e185..940c20fb 100755 --- a/vstf/vstf/controller/reporters/report/pdf/story.py +++ b/vstf/vstf/controller/reporters/report/pdf/story.py @@ -1,5 +1,12 @@ -#!/usr/bin/python -# -*- coding: utf8 -*- +############################################################################## +# 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 +############################################################################## + __doc__ = """ Story Decorator contains ImageStory, HeaderStory, PageBreakStory, TableStory, LinePlotStory, TitleStory, ParagraphStory @@ -88,44 +95,32 @@ class TableOfContentsStory(StoryDecorator): self._story.storylist.append(toc) -class uTableStory(StoryDecorator): - def new_story(self): - print "utable story" - style = ts_left - if not self._data: - print "data error " - return - self._story.storylist.append(eCommonTable(self._data, style).table) - - -class TableStory(StoryDecorator): - def new_story(self): - print "table story" - style = ts_default - self._story.storylist.append(eDataTable(self._data, style).table) - - class SpaceStory(StoryDecorator): def new_story(self): style = ps_space self._story.storylist.append(eParagraph([" ", " "], style).para) -class cTableStory(StoryDecorator): +class TableStory(StoryDecorator): def new_story(self): print "table story" style = ts_default - if self._style == 0: + if self._style == 1: + self._story.storylist.append(eDataTable(self._data, style).table) + elif self._style ==2: + style = ts_left + self._story.storylist.append(eCommonTable(self._data, style).table) + elif self._style == 3: self._story.storylist.append(eConfigTable(self._data, style).table) - elif self._style == 1: + elif self._style == 4: self._story.storylist.append(eOptionsTable(self._data, style).table) - elif self._style == 2: + elif self._style == 5: self._story.storylist.append(eProfileTable(self._data, style).table) - elif self._style == 3: + elif self._style == 6: self._story.storylist.append(eSummaryTable(self._data, style).table) - elif self._style == 4: + elif self._style == 7: self._story.storylist.append(eScenarioTable(self._data, style).table) - elif self._style == 5: + elif self._style == 8: self._story.storylist.append(eGitInfoTable(self._data, style).table) diff --git a/vstf/vstf/controller/reporters/report/pdf/styles.py b/vstf/vstf/controller/reporters/report/pdf/styles.py index d54ee8ab..2860c245 100755 --- a/vstf/vstf/controller/reporters/report/pdf/styles.py +++ b/vstf/vstf/controller/reporters/report/pdf/styles.py @@ -1,10 +1,17 @@ -#!/usr/bin/python -# -*- coding: utf8 -*- +############################################################################## +# 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 +############################################################################## + from reportlab.lib.styles import PropertySet from reportlab.lib.pagesizes import A4 from reportlab.lib import colors from reportlab.lib.styles import ParagraphStyle -from reportlab.lib.enums import TA_LEFT +import reportlab.lib.enums as ens class TemplateStyle(PropertySet): @@ -108,20 +115,14 @@ class BarChartStyle(PropertySet): "fastlink": (colors.pink, '%4.1f'), "l2switch": (colors.lightblue, '%4.1f'), "kernel rdp": (colors.lightgreen, '%4.1f'), + "ovs": (colors.purple, '%4.1f') }, background=colors.lightgrey, labelsfont=6, ) -ts_left = TableStyle( - name='left', - table_hAlign='LEFT', # LEFT,CENTRE or RIGHT - table_vAlign='BOTTOM', # BOTTOM,MIDDLE or TOP - table_colWidths=None, - table_rowHeights=None -) - +tes_default = TemplateStyle(name='default') is_default = ImageStyle(name='default') is_traffic = ImageStyle(name='traffic', image_height=150, @@ -129,12 +130,19 @@ is_traffic = ImageStyle(name='traffic', image_hAlign='CENTRE') ts_default = TableStyle(name='default') +ts_left = TableStyle( + name='left', + table_hAlign='LEFT', # LEFT,CENTRE or RIGHT + table_vAlign='BOTTOM', # BOTTOM,MIDDLE or TOP + table_colWidths=None, + table_rowHeights=None +) lps_default = LinePlotStyle(name='default') lcs_default = LineChartStyle(name='default') bcs_default = BarChartStyle(name='default') ps_head_lv1 = ParagraphStyle(name='ps_head_lv1', fontName='Courier-Bold', - alignment=TA_LEFT, # TA_CENTRE, + alignment=ens.TA_CENTER, # TA_LEFT, TA_RIGHT fontSize=13, leading=22, leftIndent=0) |