| OLD | NEW |
| (Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 from google.appengine.ext import ndb |
| 6 |
| 7 from common.base_handler import BaseHandler |
| 8 from common.base_handler import Permission |
| 9 |
| 10 |
| 11 def _FormatDatetime(dt): |
| 12 if not dt: |
| 13 return None # pragma: no cover |
| 14 else: |
| 15 return dt.strftime('%Y-%m-%d %H:%M:%S UTC') |
| 16 |
| 17 |
| 18 class Culprit(BaseHandler): |
| 19 PERMISSION_LEVEL = Permission.ANYONE |
| 20 |
| 21 def HandleGet(self): |
| 22 """Lists the build cycles in which the culprit caused failures.""" |
| 23 key = self.request.get('key', '') |
| 24 |
| 25 culprit = ndb.Key(urlsafe=key).get() |
| 26 if not culprit: # pragma: no cover |
| 27 return self.CreateError('Culprit not found', 404) |
| 28 |
| 29 def ConvertBuildInfoToADict(build_info): |
| 30 return { |
| 31 'master_name': build_info[0], |
| 32 'builder_name': build_info[1], |
| 33 'build_number': build_info[2], |
| 34 } |
| 35 |
| 36 data = { |
| 37 'project_name': culprit.project_name, |
| 38 'revision': culprit.revision, |
| 39 'cr_notified': culprit.cr_notified, |
| 40 'cr_notification_time': _FormatDatetime(culprit.cr_notification_time), |
| 41 'builds': map(ConvertBuildInfoToADict, culprit.builds), |
| 42 } |
| 43 return {'template': 'waterfall/culprit.html', 'data': data} |
| OLD | NEW |