phoglund@webrtc.org | d4f0a0e | 2012-02-01 10:59:23 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | #-*- coding: utf-8 -*- |
| 3 | # Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 4 | # |
| 5 | # Use of this source code is governed by a BSD-style license |
| 6 | # that can be found in the LICENSE file in the root of the source |
| 7 | # tree. An additional intellectual property rights grant can be found |
| 8 | # in the file PATENTS. All contributing project authors may |
| 9 | # be found in the AUTHORS file in the root of the source tree. |
| 10 | |
| 11 | """Implements the quality tracker dashboard and reporting facilities.""" |
| 12 | |
| 13 | __author__ = 'phoglund@webrtc.org (Patrik Höglund)' |
| 14 | |
phoglund@webrtc.org | 86ce46d | 2012-02-06 10:55:12 +0000 | [diff] [blame] | 15 | from google.appengine.ext.webapp import template |
phoglund@webrtc.org | d4f0a0e | 2012-02-01 10:59:23 +0000 | [diff] [blame] | 16 | import webapp2 |
| 17 | |
| 18 | import add_build_status_data |
| 19 | import add_coverage_data |
phoglund@webrtc.org | 86ce46d | 2012-02-06 10:55:12 +0000 | [diff] [blame] | 20 | import load_build_status |
| 21 | import load_coverage |
phoglund@webrtc.org | d4f0a0e | 2012-02-01 10:59:23 +0000 | [diff] [blame] | 22 | |
| 23 | |
| 24 | class ShowDashboard(webapp2.RequestHandler): |
| 25 | """Shows the dashboard page. |
| 26 | |
| 27 | The page is shown by grabbing data we have stored previously |
| 28 | in the App Engine database using the AddCoverageData handler. |
| 29 | """ |
| 30 | |
| 31 | def get(self): |
phoglund@webrtc.org | 86ce46d | 2012-02-06 10:55:12 +0000 | [diff] [blame] | 32 | build_status_loader = load_build_status.BuildStatusLoader() |
| 33 | build_status_data = build_status_loader.load_build_status_data() |
| 34 | last_updated_at = build_status_loader.load_last_modified_at() |
phoglund@webrtc.org | 914ef27 | 2012-02-27 15:42:25 +0000 | [diff] [blame] | 35 | if last_updated_at is None: |
| 36 | self._show_error_page("No data has yet been uploaded to the dashboard.") |
| 37 | return |
| 38 | |
phoglund@webrtc.org | 86ce46d | 2012-02-06 10:55:12 +0000 | [diff] [blame] | 39 | last_updated_at = last_updated_at.strftime("%Y-%m-%d %H:%M") |
| 40 | lkgr = build_status_loader.compute_lkgr() |
phoglund@webrtc.org | d4f0a0e | 2012-02-01 10:59:23 +0000 | [diff] [blame] | 41 | |
phoglund@webrtc.org | 86ce46d | 2012-02-06 10:55:12 +0000 | [diff] [blame] | 42 | coverage_loader = load_coverage.CoverageDataLoader() |
phoglund@webrtc.org | fc40276 | 2012-03-12 09:12:32 +0000 | [diff] [blame^] | 43 | small_medium_coverage_json_data = ( |
| 44 | coverage_loader.load_coverage_json_data('small_medium_tests')) |
| 45 | large_coverage_json_data = ( |
| 46 | coverage_loader.load_coverage_json_data('large_tests')) |
phoglund@webrtc.org | d4f0a0e | 2012-02-01 10:59:23 +0000 | [diff] [blame] | 47 | |
phoglund@webrtc.org | 86ce46d | 2012-02-06 10:55:12 +0000 | [diff] [blame] | 48 | page_template_filename = 'templates/dashboard_template.html' |
| 49 | self.response.write(template.render(page_template_filename, vars())) |
phoglund@webrtc.org | d4f0a0e | 2012-02-01 10:59:23 +0000 | [diff] [blame] | 50 | |
| 51 | def _show_error_page(self, error_message): |
| 52 | self.response.write('<html><body>%s</body></html>' % error_message) |
| 53 | |
| 54 | |
| 55 | app = webapp2.WSGIApplication([('/', ShowDashboard), |
| 56 | ('/add_coverage_data', |
| 57 | add_coverage_data.AddCoverageData), |
| 58 | ('/add_build_status_data', |
| 59 | add_build_status_data.AddBuildStatusData)], |
| 60 | debug=True) |