| Index: appengine/findit/handlers/culprit.py
|
| diff --git a/appengine/findit/handlers/culprit.py b/appengine/findit/handlers/culprit.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..1575f0e24a46a586dfa3dd4d748d66dd56bc6aee
|
| --- /dev/null
|
| +++ b/appengine/findit/handlers/culprit.py
|
| @@ -0,0 +1,43 @@
|
| +# Copyright 2016 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +from google.appengine.ext import ndb
|
| +
|
| +from common.base_handler import BaseHandler
|
| +from common.base_handler import Permission
|
| +
|
| +
|
| +def _FormatDatetime(dt):
|
| + if not dt:
|
| + return None # pragma: no cover
|
| + else:
|
| + return dt.strftime('%Y-%m-%d %H:%M:%S UTC')
|
| +
|
| +
|
| +class Culprit(BaseHandler):
|
| + PERMISSION_LEVEL = Permission.ANYONE
|
| +
|
| + def HandleGet(self):
|
| + """Lists the build cycles in which the culprit caused failures."""
|
| + key = self.request.get('key', '')
|
| +
|
| + culprit = ndb.Key(urlsafe=key).get()
|
| + if not culprit: # pragma: no cover
|
| + return self.CreateError('Culprit not found', 404)
|
| +
|
| + def ConvertBuildInfoToADict(build_info):
|
| + return {
|
| + 'master_name': build_info[0],
|
| + 'builder_name': build_info[1],
|
| + 'build_number': build_info[2],
|
| + }
|
| +
|
| + data = {
|
| + 'project_name': culprit.project_name,
|
| + 'revision': culprit.revision,
|
| + 'cr_notified': culprit.cr_notified,
|
| + 'cr_notification_time': _FormatDatetime(culprit.cr_notification_time),
|
| + 'builds': map(ConvertBuildInfoToADict, culprit.builds),
|
| + }
|
| + return {'template': 'waterfall/culprit.html', 'data': data}
|
|
|