summaryrefslogtreecommitdiff
path: root/tsp/scripts/publish.py
diff options
context:
space:
mode:
Diffstat (limited to 'tsp/scripts/publish.py')
-rwxr-xr-xtsp/scripts/publish.py82
1 files changed, 82 insertions, 0 deletions
diff --git a/tsp/scripts/publish.py b/tsp/scripts/publish.py
new file mode 100755
index 0000000..2ea2c77
--- /dev/null
+++ b/tsp/scripts/publish.py
@@ -0,0 +1,82 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+##
+# @author Aleksander Mistewicz <a.mistewicz@samsung.com>
+
+import argparse
+import sqlite3
+import jinja2
+
+__version__ = "0.0.1"
+__license__ = "APACHE-2.0"
+__author__ = "Aleksander Mistewicz"
+__author_email__ = "a.mistewicz@samsung.com"
+
+USAGE = "%prog <db>"
+
+AGENT = "%s/%s" % (__name__, __version__)
+
+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):
+ build_nr=str(row[2])
+ template = jinja2.Template('<tr>\n\
+<td> <a href=\"../dwn/{{ build_nr }}\">{{ sr }}</a> </td>\n\
+{% for item in row %}\
+<td> {{ item }} </td>\n\
+{% endfor %}\
+<td>\
+{% if status != \'Identical\' %}\
+ <a href=\"../img_test/{{ build_nr }}/sysctl.result\">{{ status }}</a>\
+{% else %}\
+ {{ status }} \
+{% endif %}\
+</td>\n\
+</tr>\n')
+ print template.render(build_nr=build_nr, sr=row[0], row=[row[1], build_nr, row[3]], status=row[4])
+
+def print_view(dbpath):
+ 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;")
+ for row in testresults:
+ print_row(row)
+ conn.close()
+
+def parse_arguments():
+ parser = argparse.ArgumentParser(description="HTML view generatator for results.db3")
+
+ parser.add_argument("db3", metavar='<db>', type=str,
+ help='database path')
+
+ args = parser.parse_args()
+
+ return args
+
+def main():
+ args = parse_arguments()
+ if args.db3:
+ print_view(args.db3)
+
+if __name__ == '__main__':
+ main()