-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.py
More file actions
69 lines (63 loc) · 2.41 KB
/
template.py
File metadata and controls
69 lines (63 loc) · 2.41 KB
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
'''
This python file includes code for creating html file with given result from ceilometer client.
This file only concerns about rendering output properly on html page thats it.
'''
class Template:
@staticmethod
def render(listOfMeters, fileName):
fp = open(fileName, "w")
fp.write(Template.htmlStart)
fp.write(Template.tableStart)
for row in listOfMeters:
fp.write("<tr>")
fp.write("<td>"+row['meter']+"</td>")
fp.write("<td>"+row['unit']+"</td>")
fp.write("<td>"+str(row['max'])+"</td>")
fp.write("<td>"+str(row['min'])+"</td>")
fp.write("<td>"+str(row['avg'])+"</td>")
fp.write("<td>"+str(row['sum'])+"</td>")
fp.write("</tr>")
fp.write(Template.tableEnd)
fp.write(Template.htmlEnd)
fp.close()
print "Checkout %s for output" % (fileName)
htmlStart = """
<html>
<head>
<style>
table {
color: #333; /* Lighten up font color */
font-family: Helvetica, Arial, sans-serif; /* Nicer font */
border-collapse:collapse;
border-spacing: 0;
}
td, th { border: 1px solid #CCC; height: 30px; padding:10px; } /* Make cells a bit taller */
th {
background: #F3F3F3; /* Light grey background */
font-weight: bold; /* Make sure they're bold */
}
td {
background: #FAFAFA; /* Lighter grey background */
text-align: center; /* Center our text */
}
</style>
</head>
<body>
"""
tableStart = """
<table>
<tr>
<th>Meter</th>
<th>Unit</th>
<th>Maximum</th>
<th>Minimum </th>
<th>Average</th>
<th>Sum</th>
</tr>
"""
tableEnd = """
</table>
"""
htmlEnd = """
</body></html>
"""