From: Aleksander Mistewicz Date: Thu, 13 Oct 2016 13:00:36 +0000 (+0200) Subject: Alternate row colors in html results X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F92%2F95292%2F6;p=tools%2Ftestlab%2Fmajor.git Alternate row colors in html results Change-Id: Ia95bc0578628bbd2da4eaee3c07b201983f326b4 Signed-off-by: Aleksander Mistewicz --- diff --git a/tsp/scripts/publish.py b/tsp/scripts/publish.py index 0577c6a..62f3232 100755 --- a/tsp/scripts/publish.py +++ b/tsp/scripts/publish.py @@ -31,19 +31,21 @@ USAGE = "%prog " AGENT = "%s/%s" % (__name__, __version__) +COLORS = ["#fff", "#ddd"] + def print_head(row): template = jinja2.Template('\n\ {% for item in row %}{{ item }}\n{% endfor %}\ \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('\n\ + template = jinja2.Template('\n\ {{ sr }} \n\ {% for item in row %}\ {{ item }} \n\ @@ -60,15 +62,23 @@ def print_row(row): \n\ \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():