AGENT = "%s/%s" % (__name__, __version__)
+COLORS = ["#fff", "#ddd"]
+
def print_head(row):
template = jinja2.Template('<tr>\n\
{% for item in row %}<th>{{ item }}</th>\n{% endfor %}\
</tr>\n')
print template.render(row=row)
-def print_row(row):
+def print_row(row, color):
sr=row[0]
date=row[1]
build_nr=row[2]
target=row[3]
status=row[4]
- template = jinja2.Template('<tr>\n\
+ template = jinja2.Template('<tr bgcolor=\'{{ color }}\'>\n\
<td> <a href=\"../dwn/{{ build_nr }}\">{{ sr }}</a> </td>\n\
{% for item in row %}\
<td> {{ item }} </td>\n\
</td>\n\
</tr>\n')
print template.render(build_nr=build_nr, sr=sr, row=[date, build_nr, target],\
- status=status, target=target)
+ status=status, target=target, color=color)
def print_view(dbpath):
+ def next_color(col):
+ return COLORS[(COLORS.index(col) + 1) % len(COLORS)]
conn = sqlite3.connect(dbpath)
column_names = ["SR", "Date", "\"Build nr\"", "Device", "Status"]
print_head(column_names)
testresults = conn.execute("SELECT " + ', '.join(column_names) + " FROM currentstatus;")
+ col = COLORS[0]
+ prev_sr = ''
for row in testresults:
- print_row(row)
+ sr=row[0]
+ if not sr == prev_sr:
+ prev_sr = sr
+ col = next_color(col)
+ print_row(row, col)
conn.close()
def parse_arguments():