/
reportwriter.py
106 lines (93 loc) · 2.46 KB
/
reportwriter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env python
#
# Copyright (c) 2010-2012 Corey Goldberg (corey@goldb.org)
# License: GNU LGPLv3
#
# This file is part of Multi-Mechanize | Performance Test Framework
#
class Report(object):
def __init__(self, results_dir):
self.results_dir = results_dir
self.fn = results_dir + 'results.html'
self.write_head_html()
def write_line(self, line):
with open(self.fn, 'a') as f:
f.write('%s\n' % line)
def write_head_html(self):
with open(self.fn, 'w') as f:
f.write("""\
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Multi-Mechanize - Results</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Language" content="en" />
<style type="text/css">
body {
background-color: #FFFFFF;
color: #000000;
font-family: Verdana, sans-serif;
font-size: 11px;
padding: 5px;
}
h1 {
font-size: 16px;
background: #FF9933;
margin-bottom: 0;
padding-left: 5px;
padding-top: 2px;
}
h2 {
font-size: 13px;
background: #C0C0C0;
padding-left: 5px;
margin-top: 2em;
margin-bottom: .75em;
}
h3 {
font-size: 12px;
background: #EEEEEE;
padding-left: 5px;
margin-bottom: 0.5em;
}
h4 {
font-size: 11px;
padding-left: 20px;
margin-bottom: 0;
}
p {
margin: 0;
padding: 0;
}
table {
margin-left: 10px;
}
td {
text-align: right;
color: #000000;
background: #FFFFFF;
padding-left: 10px;
padding-right: 10px;
padding-bottom: 0;
}
th {
text-align: center;
padding-right: 10px;
padding-left: 10px;
color: #000000;
background: #FFFFFF;
}
div.summary {
padding-left: 20px;
}
</style>
</head>
<body>
""")
def write_closing_html(self):
with open(self.fn, 'a') as f:
f.write("""\
</body>
</html>
""")