diff options
Diffstat (limited to 'testsuites/vstf/vstf_scripts/vstf/controller/reporters')
18 files changed, 317 insertions, 121 deletions
diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/__init__.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/__init__.py index df7d24d0..83b8d15d 100644 --- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/__init__.py +++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/__init__.py @@ -6,4 +6,3 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## - diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/mail/__init__.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/mail/__init__.py index df7d24d0..83b8d15d 100644 --- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/mail/__init__.py +++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/mail/__init__.py @@ -6,4 +6,3 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## - diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/mail/mail.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/mail/mail.py index 6792ad91..c217f9e5 100644 --- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/mail/mail.py +++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/mail/mail.py @@ -21,6 +21,7 @@ PASSWD = None class Mail(object): + def __init__(self, srv=SRV, user=USER, passwd=PASSWD): self.srv = srv self.user = USER @@ -81,7 +82,10 @@ class Mail(object): def attach_files(self, files): for _file in files: part = MIMEApplication(open(_file, "rb").read()) - part.add_header('Content-Disposition', 'attachment', filename=os.path.basename(_file)) + part.add_header( + 'Content-Disposition', + 'attachment', + filename=os.path.basename(_file)) self._msg.attach(part) def send(self): @@ -114,11 +118,11 @@ if __name__ == "__main__": <head> <title>vstf</title> </head> - + <body> hello vstf </body> - + </html> """ m.attach_text(context, m.HTML) diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/mail/sendmail.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/mail/sendmail.py index a4d7bb0a..42f991a8 100644 --- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/mail/sendmail.py +++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/mail/sendmail.py @@ -15,6 +15,7 @@ LOG = logging.getLogger(__name__) class SendMail(object): + def __init__(self, mail_info): self._mail_info = mail_info @@ -32,7 +33,9 @@ class SendMail(object): if 'attach' in self._mail_info['body']: send.attach_files(self._mail_info['body']['attach']) - send.attach_text(self._mail_info['body']['content'], self._mail_info['body']['subtype']) + send.attach_text( + self._mail_info['body']['content'], + self._mail_info['body']['subtype']) send.attach_title(self._mail_info['body']['subject']) send.send() @@ -50,11 +53,11 @@ def unit_test(): <head> <title>vstf</title> </head> - + <body> hello vstf </body> - + </html> """ mail_settings.set_subtype('html') diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/__init__.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/__init__.py index 547db686..83b8d15d 100644 --- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/__init__.py +++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/__init__.py @@ -6,5 +6,3 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## - - diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/candy_generator.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/candy_generator.py index ea296550..a3285c9e 100644 --- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/candy_generator.py +++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/candy_generator.py @@ -16,6 +16,7 @@ LOG = logging.getLogger(__name__) class CandyGenerator(object): + def __init__(self, task): self._task = task @@ -99,7 +100,8 @@ class CandyGenerator(object): "data": scenario_data.get_latency_bardata(case) } table = scenario_data.get_latency_tabledata(case) - test_section = self.create_test(sectionid, params_info, table, draw) + test_section = self.create_test( + sectionid, params_info, table, draw) scenario_chapter[name] = test_section return scenario_chapter @@ -125,7 +127,10 @@ class CandyGenerator(object): def main(): from vstf.common.log import setup_logging - setup_logging(level=logging.DEBUG, log_file="/var/log/vstf/vstf-candy.log", clevel=logging.INFO) + setup_logging( + level=logging.DEBUG, + log_file="/var/log/vstf/vstf-candy.log", + clevel=logging.INFO) dbase = DbManage() taskid = dbase.get_last_taskid() @@ -135,4 +140,3 @@ def main(): creator.create("Tn") if __name__ == '__main__': main() - diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/data_factory.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/data_factory.py index f9fc69d9..ded94ebd 100644 --- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/data_factory.py +++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/data_factory.py @@ -12,12 +12,14 @@ import vstf.common.constants as cst class DataProvider(object): + def __init__(self, taskid, dbase): self._dbase = dbase self._taskid = taskid class CommonData(DataProvider): + def get_taskname(self): return self._dbase.query_taskname(self._taskid) @@ -67,6 +69,7 @@ class CommonData(DataProvider): class ScenarioData(DataProvider): + def __init__(self, taskid, dbase, scenario): print "ScenarioData in" DataProvider.__init__(self, taskid, dbase) @@ -96,13 +99,15 @@ class ScenarioData(DataProvider): return query def is_provider_start(self, case, provider): - count = self._dbase.query_case_provider_count(self._taskid, case, provider) + count = self._dbase.query_case_provider_count( + self._taskid, case, provider) if count: return True return False def is_type_provider_start(self, case, provider, ptype): - count = self._dbase.query_case_type_provider_count(self._taskid, case, provider, ptype) + count = self._dbase.query_case_type_provider_count( + self._taskid, case, provider, ptype) if count: return True return False @@ -133,7 +138,12 @@ class ScenarioData(DataProvider): test_type = "frameloss" return self.get_summary_tabledata(case, provider, test_type) - def get_summary_tabledata(self, case, provider, test_type, table_type='pdf'): + def get_summary_tabledata( + self, + case, + provider, + test_type, + table_type='pdf'): table_head = [] table_body = [] type_title = { @@ -142,41 +152,77 @@ class ScenarioData(DataProvider): } tools = self.get_test_tools(case) if "spirent" in tools: - table_body = self._dbase.query_summary_table(self._taskid, case, provider, test_type) + table_body = self._dbase.query_summary_table( + self._taskid, case, provider, test_type) if 'pdf' == table_type: - table_head = [ - ["FrameSize (byte)", test_type, "", "", "", "Latency(uSec)", "", ""], - ["", " Mpps ", " " + type_title[test_type] + " (%) ", "CPU Used (%)", " Mpps/Ghz ", - " Min ", " Max ", " Avg "] - ] + table_head = [["FrameSize (byte)", + test_type, + "", + "", + "", + "Latency(uSec)", + "", + ""], + ["", + " Mpps ", + " " + type_title[test_type] + " (%) ", + "CPU Used (%)", + " Mpps/Ghz ", + " Min ", + " Max ", + " Avg "]] else: - table_head = [ - ["FrameSize (byte)", " Mpps ", " " + type_title[test_type] + " (%) ", "CPU Used (%)", - " Mpps/Ghz ", "MinLatency(uSec)", "MaxLatency(uSec)", "AvgLatency(uSec)"], - ] + table_head = [["FrameSize (byte)", + " Mpps ", + " " + type_title[test_type] + " (%) ", + "CPU Used (%)", + " Mpps/Ghz ", + "MinLatency(uSec)", + "MaxLatency(uSec)", + "AvgLatency(uSec)"], + ] else: - table_body = self._dbase.query_summary_simpletable(self._taskid, case, provider, test_type) + table_body = self._dbase.query_summary_simpletable( + self._taskid, case, provider, test_type) if 'pdf' == table_type: - table_head = [ - ["FrameSize (byte)", test_type, "", "", "", "Latency(uSec)"], - ["", " Mpps ", " " + type_title[test_type] + " (%)", "CPU Used (%)", " Mpps/Ghz ", - " Avg "] - ] + table_head = [["FrameSize (byte)", + test_type, + "", + "", + "", + "Latency(uSec)"], + ["", + " Mpps ", + " " + type_title[test_type] + " (%)", + "CPU Used (%)", + " Mpps/Ghz ", + " Avg "]] else: - table_head = [ - ["FrameSize (byte)", " Mpps ", " " + type_title[test_type] + " (%) ", "CPU Used (%)", - " Mpps/Ghz ", "AvgLatency(uSec)"], - ] + table_head = [["FrameSize (byte)", + " Mpps ", + " " + type_title[test_type] + " (%) ", + "CPU Used (%)", + " Mpps/Ghz ", + "AvgLatency(uSec)"], + ] return table_head + table_body def get_ratedata(self, testid, test_type): - table_head = [ - ["FrameSize (bytes)", "Bandwidth(Mpps)", "Load (%)", "CPU Usage(%)", "Mpps/Ghz", "AvgLatency(uSec)"], - ] + table_head = [["FrameSize (bytes)", + "Bandwidth(Mpps)", + "Load (%)", + "CPU Usage(%)", + "Mpps/Ghz", + "AvgLatency(uSec)"], + ] query = self._dbase.query_testdata(testid, test_type) table_body = [] for item in query: - table_body.append([item.AvgFrameSize, item.Bandwidth, item.OfferedLoad, item.CPU, item.MppspGhz, + table_body.append([item.AvgFrameSize, + item.Bandwidth, + item.OfferedLoad, + item.CPU, + item.MppspGhz, item.AverageLatency]) result = [] if table_body: @@ -203,20 +249,29 @@ class ScenarioData(DataProvider): for provider in cst.PROVIDERS: if self.is_provider_start(case, provider): if item == 'Percent': - query = self._dbase.query_load(self._taskid, case, provider, test_type) + query = self._dbase.query_load( + self._taskid, case, provider, test_type) elif item == 'Mpps': - query = self._dbase.query_bandwidth(self._taskid, case, provider, test_type) + query = self._dbase.query_bandwidth( + self._taskid, case, provider, test_type) else: - query = self._dbase.query_avglatency(self._taskid, case, provider, test_type) + query = self._dbase.query_avglatency( + self._taskid, case, provider, test_type) query = map(lambda x: list(x), zip(*query)) if query: - table_head = [[type_dict["FrameSize"]] + map(lambda x: " %4d " % (x), query[0])] + table_head = [[type_dict["FrameSize"]] + + map(lambda x: " %4d " % (x), query[0])] if item == "Avg": - data = map(lambda x: item_dict[item] + "%.1f" % x + item_dict[item], query[1]) + data = map( + lambda x: item_dict[item] + "%.1f" % + x + item_dict[item], query[1]) else: - data = map(lambda x: item_dict[item] + "%.2f" % x + item_dict[item], query[1]) + data = map( + lambda x: item_dict[item] + "%.2f" % + x + item_dict[item], query[1]) if item == "Mpps": - line_table = map(lambda x: "%.2f" % (line_speed * 1000 / (8 * (x + 20))), query[0]) + line_table = map(lambda x: "%.2f" % ( + line_speed * 1000 / (8 * (x + 20))), query[0]) table.append([type_dict[provider]] + data) if table: if item == "Mpps": @@ -260,7 +315,8 @@ class ScenarioData(DataProvider): result = [] if table_data: ytitle = "Average Latency (uSec)" - category_names = map(lambda x: "FS:%4d" % int(float(x)) + "LOAD:50", table_data[0][1:]) + category_names = map(lambda x: "FS:%4d" % + int(float(x)) + "LOAD:50", table_data[0][1:]) bar_ = map(lambda x: x[0], table_data[1:]) data = map(lambda x: x[1:], table_data[1:]) result = [ytitle, category_names, bar_, data] @@ -268,10 +324,12 @@ class ScenarioData(DataProvider): def get_bardata(self, case, provider, test_type): if test_type == "latency": - query = self._dbase.query_avglatency(self._taskid, case, provider, test_type) + query = self._dbase.query_avglatency( + self._taskid, case, provider, test_type) item = "Avg" else: - query = self._dbase.query_load(self._taskid, case, provider, test_type) + query = self._dbase.query_load( + self._taskid, case, provider, test_type) item = "Percent" title_dict = { @@ -290,7 +348,9 @@ class ScenarioData(DataProvider): query = map(lambda x: list(x), zip(*query)) result = [] if query: - category_names = map(lambda x: "FS:%4d" % x + name_dict[item], query[0]) + category_names = map( + lambda x: "FS:%4d" % + x + name_dict[item], query[0]) data = query[1:] bar_ = [color_dict[item]] result = [ytitle, category_names, bar_, data] @@ -298,6 +358,7 @@ class ScenarioData(DataProvider): class TaskData(object): + def __init__(self, taskid, dbase): self.__common = CommonData(taskid, dbase) scenario_list = self.__common.get_scenariolist() @@ -312,6 +373,7 @@ class TaskData(object): class HistoryData(DataProvider): + def get_data(self, task_list, case, provider, ttype, item): """ @provider in ["fastlink", "rdp", "l2switch", ""] @@ -324,17 +386,18 @@ class HistoryData(DataProvider): sizes = [] for taskid in task_list: if item == 'ratep': - query = self._dbase.query_bandwidth(taskid, case, provider, ttype) + query = self._dbase.query_bandwidth( + taskid, case, provider, ttype) else: - query = self._dbase.query_avglatency(taskid, case, provider, ttype) + query = self._dbase.query_avglatency( + taskid, case, provider, ttype) if query: data = {} for size, value in query: data[size] = value sizes.extend(data.keys()) - sizes = {}.fromkeys(sizes).keys() - sizes.sort() + sizes = sorted({}.fromkeys(sizes).keys()) datas.append({taskid: data}) result = [] @@ -367,7 +430,10 @@ class HistoryData(DataProvider): return task_list def get_history_info(self, case): - provider_dict = {"fastlink": "Fast Link ", "l2switch": "L2Switch ", "rdp": "Kernel RDP "} + provider_dict = { + "fastlink": "Fast Link ", + "l2switch": "L2Switch ", + "rdp": "Kernel RDP "} ttype_dict = { "throughput": "Throughput Testing ", "frameloss": "Frame Loss Testing ", @@ -390,7 +456,8 @@ class HistoryData(DataProvider): item = "ratep" for provider in cst.PROVIDERS: - table_data = self.get_data(task_list, case, provider, ttype, item) + table_data = self.get_data( + task_list, case, provider, ttype, item) if table_data: data = { "title": provider_dict[provider] + items_dict[item], diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/html/__init__.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/html/__init__.py index df7d24d0..83b8d15d 100644 --- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/html/__init__.py +++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/html/__init__.py @@ -6,4 +6,3 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## - diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/html/html_base.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/html/html_base.py index 5769da79..02606b4b 100644 --- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/html/html_base.py +++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/html/html_base.py @@ -13,6 +13,7 @@ import vstf.common.pyhtml as pyhtm class HtmlBase(object): + def __init__(self, provider): self._page = pyhtm.PyHtml('Html Text') self._provider = provider diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/html/htmlcreator.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/html/htmlcreator.py index 695ea37f..f866f185 100644 --- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/html/htmlcreator.py +++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/html/htmlcreator.py @@ -20,6 +20,7 @@ LOG = logging.getLogger(__name__) class HtmlCreator(HtmlBase): + def create_story(self): self.add_context() @@ -70,7 +71,10 @@ class HtmlCreator(HtmlBase): def unit_test(): from vstf.common.log import setup_logging - setup_logging(level=logging.DEBUG, log_file="/var/log/html-creator.log", clevel=logging.INFO) + setup_logging( + level=logging.DEBUG, + log_file="/var/log/html-creator.log", + clevel=logging.INFO) out_file = "vstf_report.html" diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/__init__.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/__init__.py index df7d24d0..83b8d15d 100644 --- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/__init__.py +++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/__init__.py @@ -6,4 +6,3 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## - diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/element.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/element.py index ef8b54df..6622281b 100644 --- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/element.py +++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/element.py @@ -32,8 +32,16 @@ from vstf.controller.reporters.report.pdf.styles import * class eImage(Image): """ an image(digital picture)which contains the function of auto zoom picture """ - def __init__(self, filename, width=None, height=None, kind='direct', mask="auto", lazy=1, hAlign='CENTRE', - vAlign='BOTTOM'): + def __init__( + self, + filename, + width=None, + height=None, + kind='direct', + mask="auto", + lazy=1, + hAlign='CENTRE', + vAlign='BOTTOM'): Image.__init__(self, filename, None, None, kind, mask, lazy) print height, width print self.drawHeight, self.drawWidth @@ -78,6 +86,7 @@ class eTable(object): class eCommonTable(eTable): + def analysisData(self, data): self._style = [ ('ALIGN', (0, 0), (-1, -1), 'CENTER'), @@ -89,6 +98,7 @@ class eCommonTable(eTable): class eConfigTable(eTable): + def analysisData(self, data): self._style = [ ('ALIGN', (0, 0), (-1, -1), 'CENTER'), @@ -113,6 +123,7 @@ class eConfigTable(eTable): class eSummaryTable(eTable): + def analysisData(self, data): self._style = [ ('ALIGN', (0, 0), (-1, -1), 'CENTER'), @@ -127,6 +138,7 @@ class eSummaryTable(eTable): class eGitInfoTable(eTable): + def analysisData(self, data): self._style = [ ('ALIGN', (0, 0), (-1, -1), 'CENTER'), @@ -141,6 +153,7 @@ class eGitInfoTable(eTable): class eScenarioTable(eTable): + def analysisData(self, data): self._style = [ ('ALIGN', (0, 0), (-1, -1), 'CENTER'), @@ -157,6 +170,7 @@ class eScenarioTable(eTable): class eOptionsTable(eTable): + def analysisData(self, data): self._style = [ ('ALIGN', (0, 0), (-1, -1), 'CENTER'), @@ -181,6 +195,7 @@ class eOptionsTable(eTable): class eProfileTable(eTable): + def analysisData(self, data): self._style = [ ('ALIGN', (0, 0), (-1, -1), 'CENTER'), @@ -194,6 +209,7 @@ class eProfileTable(eTable): class eDataTable(eTable): + def analysisData(self, data): result = data self._style = [ @@ -229,6 +245,7 @@ class eDataTable(eTable): class eGraphicsTable(eTable): + def analysisData(self, data): self._style = [ ('ALIGN', (0, 0), (-1, -1), 'CENTER'), @@ -238,12 +255,14 @@ class eGraphicsTable(eTable): class noScaleXValueAxis(XValueAxis): + def __init__(self): XValueAxis.__init__(self) def makeTickLabels(self): g = Group() - if not self.visibleLabels: return g + if not self.visibleLabels: + return g f = self._labelTextFormat # perhaps someone already set it if f is None: @@ -307,14 +326,17 @@ class noScaleXValueAxis(XValueAxis): txt = f(t) else: raise ValueError('Invalid labelTextFormat %s' % f) - if post: txt = post % txt + if post: + txt = post % txt pos[d] = v label.setOrigin(*pos) label.setText(txt) - # special property to ensure a label doesn't project beyond the bounds of an x-axis + # special property to ensure a label doesn't project beyond + # the bounds of an x-axis if self.keepTickLabelsInside: - if isinstance(self, XValueAxis): # not done yet for y axes + if isinstance( + self, XValueAxis): # not done yet for y axes a_x = self._x if not i: # first one x0, y0, x1, y1 = label.getBounds() @@ -324,7 +346,8 @@ class noScaleXValueAxis(XValueAxis): a_x1 = a_x + self._length x0, y0, x1, y1 = label.getBounds() if x1 > a_x1: - label = label.clone(dx=label.dx - x1 + a_x1) + label = label.clone( + dx=label.dx - x1 + a_x1) g.add(label) return g @@ -342,8 +365,10 @@ class noScaleXValueAxis(XValueAxis): The chart first configures the axis, then asks it to """ assert self._configured, "Axis cannot scale numbers before it is configured" - if value is None: value = 0 - # this could be made more efficient by moving the definition of org and sf into the configuration + if value is None: + value = 0 + # this could be made more efficient by moving the definition of org and + # sf into the configuration org = (self._x, self._y)[self._dataIndex] sf = self._length / (len(self._tickValues) + 1) if self.reverseDirection: @@ -353,6 +378,7 @@ class noScaleXValueAxis(XValueAxis): class noScaleLinePlot(LinePlot): + def __init__(self): LinePlot.__init__(self) self.xValueAxis = noScaleXValueAxis() @@ -373,7 +399,8 @@ class noScaleLinePlot(LinePlot): for colNo in range(len_row): datum = self.data[rowNo][colNo] # x, y value x = self.x + self.width / (len_row + 1) * (colNo + 1) - self.xValueAxis.labels[colNo].x = self.x + self.width / (len_row + 1) * (colNo + 1) + self.xValueAxis.labels[colNo].x = self.x + \ + self.width / (len_row + 1) * (colNo + 1) y = self.yValueAxis.scale(datum[1]) # print self.width, " ", x line.append((x, y)) @@ -383,6 +410,7 @@ class noScaleLinePlot(LinePlot): # def _innerDrawLabel(self, rowNo, colNo, x, y): # return None class eLinePlot(object): + def __init__(self, data, style): self._lpstyle = style self._linename = data[0] @@ -485,9 +513,11 @@ class eLinePlot(object): for i in range(line_cnts): styleIndex = i % sytle_cnts lp.lines[i].strokeColor = self._lpstyle.linestyle[styleIndex][0] - lp.lines[i].symbol = makeMarker(self._lpstyle.linestyle[styleIndex][1]) + lp.lines[i].symbol = makeMarker( + self._lpstyle.linestyle[styleIndex][1]) lp.lines[i].strokeWidth = self._lpstyle.linestyle[styleIndex][2] - color_paris.append((self._lpstyle.linestyle[styleIndex][0], self._linename[i])) + color_paris.append( + (self._lpstyle.linestyle[styleIndex][0], self._linename[i])) # lp.lineLabels[i].strokeColor = self._lpstyle.linestyle[styleIndex][0] lp.lineLabelFormat = self._lpstyle.format[0] @@ -501,8 +531,6 @@ class eLinePlot(object): lp.yValueAxis.valueMin, lp.yValueAxis.valueMax, lp.yValueAxis.valueSteps = self._yvalue - - # lp.xValueAxis.forceZero = 0 # lp.xValueAxis.avoidBoundFrac = 1 # lp.xValueAxis.tickDown = 3 @@ -540,6 +568,7 @@ class eLinePlot(object): class eHorizontalLineChart(object): + def __init__(self, data, style): self._lcstyle = style if len(data) < 1: @@ -630,9 +659,11 @@ class eHorizontalLineChart(object): for i in range(line_cnts): styleIndex = i % sytle_cnts lc.lines[i].strokeColor = self._lcstyle.linestyle[styleIndex][0] - lc.lines[i].symbol = makeMarker(self._lcstyle.linestyle[styleIndex][1]) + lc.lines[i].symbol = makeMarker( + self._lcstyle.linestyle[styleIndex][1]) lc.lines[i].strokeWidth = self._lcstyle.linestyle[styleIndex][2] - color_paris.append((self._lcstyle.linestyle[styleIndex][0], self._linename[i])) + color_paris.append( + (self._lcstyle.linestyle[styleIndex][0], self._linename[i])) lc.lineLabels.fontSize = self._lcstyle.labelsfont - 2 @@ -660,6 +691,7 @@ class eHorizontalLineChart(object): class eBarChartColumn(object): + def __init__(self, data, style): self._bcstyle = style if len(data) < 4: @@ -702,7 +734,10 @@ class eBarChartColumn(object): color_paris = [] for i in range(bar_cnt): bc.bars[i].fillColor = self._bcstyle.pillarstyle[self._bar[i]][0] - color_paris.append((self._bcstyle.pillarstyle[self._bar[i]][0], self._bar[i])) + color_paris.append( + (self._bcstyle.pillarstyle[ + self._bar[i]][0], + self._bar[i])) bc.fillColor = self._bcstyle.background bc.barLabels.fontName = 'Helvetica' @@ -761,6 +796,7 @@ class eBarChartColumn(object): class eParagraph(object): + def __init__(self, data, style): self._pstyle = style self._data = self.analysisData(data) diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/pdfcreator.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/pdfcreator.py index c33974ec..67f988c9 100644 --- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/pdfcreator.py +++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/pdfcreator.py @@ -22,6 +22,7 @@ LOG = logging.getLogger(__name__) class PdfCreator(object): + def __init__(self, provider): self._provider = provider self._story = [] @@ -114,7 +115,10 @@ class PdfCreator(object): def main(): from vstf.common.log import setup_logging - setup_logging(level=logging.DEBUG, log_file="/var/log/pdf-creator.log", clevel=logging.INFO) + setup_logging( + level=logging.DEBUG, + log_file="/var/log/pdf-creator.log", + clevel=logging.INFO) out_file = "vstf_report.pdf" diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/pdftemplate.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/pdftemplate.py index 69c65401..7e287814 100644 --- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/pdftemplate.py +++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/pdftemplate.py @@ -13,9 +13,11 @@ 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 +from functools import reduce class BaseDocTemplate(SimpleDocTemplate): + def __init__(self, filename, **kw): self.allowSplitting = 0 SimpleDocTemplate.__init__(self, filename, **kw) @@ -34,6 +36,7 @@ class BaseDocTemplate(SimpleDocTemplate): class PdfTemplate(object): + def __init__(self, title, logo, header, footer, note=[], style="default"): self._style = TemplateStyle(name=style) self._title = title @@ -41,7 +44,8 @@ class PdfTemplate(object): #self._header = header[0] self._footer = footer self._note = note - info = " Generated on %s " % time.strftime(cst.TIME_FORMAT2, time.localtime()) + info = " Generated on %s " % time.strftime( + cst.TIME_FORMAT2, time.localtime()) self._note += [info] def myFirstPage(self, canvas, doc): @@ -54,46 +58,78 @@ class PdfTemplate(object): sizes = (self._style.page_wight, self._style.page_height) doc = BaseDocTemplate(output, pagesize=sizes) # doc.build(story, onFirstPage=self.myFirstPage, onLaterPages=self.myLaterPages) - doc.multiBuild(story, onFirstPage=self.myFirstPage, onLaterPages=self.myLaterPages) + doc.multiBuild( + story, + onFirstPage=self.myFirstPage, + onLaterPages=self.myLaterPages) class PdfVswitch(PdfTemplate): + def myFirstPage(self, canvas, doc): canvas.saveState() title_lines = len(self._title) line_size = [self._style.title_size] * title_lines line_size.append(0) - canvas.drawImage(self._logo, - (self._style.page_wight - self._style.logo_width) / 2.0, - self._style.page_height / 2.0 + (1 + self._style.title_leading) * reduce(lambda x, y: x + y, - line_size), - self._style.logo_width, - self._style.logo_height - ) + canvas.drawImage( + self._logo, + (self._style.page_wight - + self._style.logo_width) / + 2.0, + self._style.page_height / + 2.0 + + ( + 1 + + self._style.title_leading) * + reduce( + lambda x, + y: x + + y, + line_size), + self._style.logo_width, + self._style.logo_height) for i in range(title_lines): canvas.setFont(self._style.title_font, line_size[i]) - canvas.drawCentredString(self._style.page_wight / 2.0, - self._style.page_height / 2.0 + (1 + self._style.title_leading) * reduce( - lambda x, y: x + y, line_size[i + 1:]), - self._title[i] - ) + canvas.drawCentredString( + self._style.page_wight / + 2.0, + self._style.page_height / + 2.0 + + ( + 1 + + self._style.title_leading) * + reduce( + lambda x, + y: x + + y, + line_size[ + i + + 1:]), + self._title[i]) size = self._style.body_size canvas.setFont(self._style.body_font, size) note_line = len(self._note) for i in range(note_line): print self._note[i] - canvas.drawCentredString(self._style.page_wight / 2.0, - self._style.page_height / 5.0 + (1 + self._style.body_leading) * size * ( - note_line - i - 1), - self._note[i] - ) + canvas.drawCentredString(self._style.page_wight / + 2.0, self._style.page_height / + 5.0 + + (1 + + self._style.body_leading) * + size * + (note_line - + i - + 1), self._note[i]) size = self._style.body_size - 2 canvas.setFont(self._style.body_font, size) - canvas.drawCentredString(self._style.page_wight / 2.0, - self._style.page_bottom / 2.0 + (1 + self._style.body_leading) * size, - self._footer[0]) + canvas.drawCentredString(self._style.page_wight / + 2.0, self._style.page_bottom / + 2.0 + + (1 + + self._style.body_leading) * + size, self._footer[0]) canvas.restoreState() def myLaterPages(self, canvas, doc): @@ -106,9 +142,7 @@ class PdfVswitch(PdfTemplate): ) size = self._style.body_size - 2 canvas.setFont(self._style.body_font, size) - canvas.drawCentredString(self._style.page_wight / 2.0, - self._style.page_bottom - 24, - "%s%s Page %2d " % (self._footer[0], " " * 8, doc.page - 1) - ) + canvas.drawCentredString( + self._style.page_wight / 2.0, self._style.page_bottom - 24, "%s%s Page %2d " % + (self._footer[0], " " * 8, doc.page - 1)) canvas.restoreState() - diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/story.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/story.py index 940c20fb..f1442fe7 100644 --- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/story.py +++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/pdf/story.py @@ -21,6 +21,7 @@ from element import * class Story(object): + def __init__(self): self._storylist = [] @@ -30,6 +31,7 @@ class Story(object): class StoryDecorator(Story): + def __init__(self, story, data=None, style=None): self._story = story self._data = data @@ -47,6 +49,7 @@ class StoryDecorator(Story): class ImageStory(StoryDecorator): + def new_story(self): print "Image Story" for filename in self._data: @@ -60,7 +63,12 @@ class ImageStory(StoryDecorator): image_hAlign = style.image_hAlign image_vAlign = style.image_vAlign self._story.storylist.append( - eImage(filename, image_width, image_height, hAlign=image_hAlign, vAlign=image_vAlign)) + eImage( + filename, + image_width, + image_height, + hAlign=image_hAlign, + vAlign=image_vAlign)) else: style = is_default image_height = style.image_height @@ -69,22 +77,30 @@ class ImageStory(StoryDecorator): image_vAlign = style.image_vAlign # self._story.storylist.append(eGraphicsTable([[' ' * 5, eImage(filename, image_width, image_height, hAlign=image_hAlign, vAlign=image_vAlign)]], ts_left).table) self._story.storylist.append( - eImage(filename, image_width, image_height, hAlign=image_hAlign, vAlign=image_vAlign)) + eImage( + filename, + image_width, + image_height, + hAlign=image_hAlign, + vAlign=image_vAlign)) class HeaderStory(StoryDecorator): + def new_story(self): print "header story" self._story.storylist.append(PageBreak()) class PageBreakStory(StoryDecorator): + def new_story(self): print "PageBreak story" self._story.storylist.append(PageBreak()) class TableOfContentsStory(StoryDecorator): + def new_story(self): print "TableOfContents story" self._data = [" ", " ", "Table Of Contents", ""] @@ -96,35 +112,43 @@ class TableOfContentsStory(StoryDecorator): class SpaceStory(StoryDecorator): + def new_story(self): style = ps_space self._story.storylist.append(eParagraph([" ", " "], style).para) class TableStory(StoryDecorator): + def new_story(self): print "table story" style = ts_default if self._style == 1: self._story.storylist.append(eDataTable(self._data, style).table) - elif self._style ==2: + 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 == 4: - self._story.storylist.append(eOptionsTable(self._data, style).table) + self._story.storylist.append( + eOptionsTable(self._data, style).table) elif self._style == 5: - self._story.storylist.append(eProfileTable(self._data, style).table) + self._story.storylist.append( + eProfileTable(self._data, style).table) elif self._style == 6: - self._story.storylist.append(eSummaryTable(self._data, style).table) + self._story.storylist.append( + eSummaryTable(self._data, style).table) elif self._style == 7: - self._story.storylist.append(eScenarioTable(self._data, style).table) + self._story.storylist.append( + eScenarioTable(self._data, style).table) elif self._style == 8: - self._story.storylist.append(eGitInfoTable(self._data, style).table) + self._story.storylist.append( + eGitInfoTable(self._data, style).table) class LinePlotStory(StoryDecorator): + def new_story(self): print "LinePlot" style = lps_default @@ -137,18 +161,21 @@ class LinePlotStory(StoryDecorator): class LineChartStory(StoryDecorator): + def new_story(self): print "LineChartStory: " style = lcs_default if not self._data: print "data error " return - data = eGraphicsTable([[eHorizontalLineChart(self._data, style).draw]]).table + data = eGraphicsTable( + [[eHorizontalLineChart(self._data, style).draw]]).table if data: self._story.storylist.append(data) class BarChartStory(StoryDecorator): + def new_story(self): print "BarChartStory: " style = bcs_default @@ -156,12 +183,14 @@ class BarChartStory(StoryDecorator): print "data error " return - data = eGraphicsTable([[eBarChartColumn(self._data, style).draw]]).table + data = eGraphicsTable( + [[eBarChartColumn(self._data, style).draw]]).table if data: self._story.storylist.append(data) class ParagraphStory(StoryDecorator): + def new_story(self): print "Paragraph Story" style = ps_body @@ -174,6 +203,7 @@ class ParagraphStory(StoryDecorator): class TitleStory(StoryDecorator): + def new_story(self): print "Paragraph Story" if self._style - 1 in range(9): diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/provider/html_provider.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/provider/html_provider.py index 74c4c593..2e0863ec 100644 --- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/provider/html_provider.py +++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/provider/html_provider.py @@ -15,6 +15,7 @@ from vstf.controller.settings.template_settings import TemplateSettings class HtmlProvider(object): + def __init__(self, info, style): self._info = info self._style = style @@ -32,7 +33,10 @@ class HtmlProvider(object): def main(): from vstf.common.log import setup_logging - setup_logging(level=logging.DEBUG, log_file="/var/log/html-provder.log", clevel=logging.INFO) + setup_logging( + level=logging.DEBUG, + log_file="/var/log/html-provder.log", + clevel=logging.INFO) html_settings = HtmlSettings() LOG.info(html_settings.settings) @@ -42,4 +46,4 @@ def main(): LOG.info(provider.get_context) if __name__ == '__main__': - main()
\ No newline at end of file + main() diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/provider/pdf_provider.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/provider/pdf_provider.py index e1cb09ef..f7752016 100644 --- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/provider/pdf_provider.py +++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/report/provider/pdf_provider.py @@ -15,6 +15,7 @@ from vstf.controller.settings.template_settings import TemplateSettings class PdfProvider(object): + def __init__(self, info): self._info = info @@ -37,7 +38,10 @@ class PdfProvider(object): def main(): from vstf.common.log import setup_logging - setup_logging(level=logging.DEBUG, log_file="/var/log/pdf-provider.log", clevel=logging.INFO) + setup_logging( + level=logging.DEBUG, + log_file="/var/log/pdf-provider.log", + clevel=logging.INFO) info = TemplateSettings() provider = PdfProvider(info.settings) @@ -46,4 +50,4 @@ def main(): LOG.info(provider.get_context) if __name__ == '__main__': - main()
\ No newline at end of file + main() diff --git a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/reporter.py b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/reporter.py index 654c9b83..ea0a1ad0 100644 --- a/testsuites/vstf/vstf_scripts/vstf/controller/reporters/reporter.py +++ b/testsuites/vstf/vstf_scripts/vstf/controller/reporters/reporter.py @@ -30,6 +30,7 @@ LOG = logging.getLogger(__name__) class Report(object): + def __init__(self, dbase, rpath): """ @@ -47,7 +48,10 @@ class Report(object): 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_FORMAT3))) + out_file = os.path.join( + self._rpath, "vstf_report_%s_%s.pdf" % + (scenario, time.strftime( + cst.TIME_FORMAT3))) LOG.info(out_file) creator.create(scenario) info = TemplateSettings() @@ -90,7 +94,10 @@ class Report(object): def main(): from vstf.common.log import setup_logging - setup_logging(level=logging.DEBUG, log_file="/var/log/vstf/vstf-reporter.log", clevel=logging.INFO) + setup_logging( + level=logging.DEBUG, + log_file="/var/log/vstf/vstf-reporter.log", + clevel=logging.INFO) parser = argparse.ArgumentParser(add_help=True) parser.add_argument('-rpath', |