OLD | NEW |
| (Empty) |
1 # Copyright (c) 2014 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 | |
6 """JSON interface which returns the most recent results for each builder.""" | |
7 | |
8 | |
9 import buildbot.status.web.base as base | |
10 import builder_name_schema | |
11 | |
12 from buildbot.status.web.status_json import JsonResource | |
13 from twisted.python import log | |
14 | |
15 | |
16 class BuilderStatusesJsonResource(JsonResource): | |
17 """Returns the results of the last completed build for each builder. | |
18 | |
19 This is essentially a JSON equivalent of the upstream | |
20 horizontal_one_box_per_builder HTML page, as in | |
21 third_party/chromium_buildbot/scripts/master/chromium_status_bb8.py. | |
22 """ | |
23 | |
24 def asDict(self, request): | |
25 builders = request.args.get('builder', self.status.getBuilderNames()) | |
26 data = {'builders': []} | |
27 for builder_name in builders: | |
28 if builder_name_schema.IsTrybot(builder_name): | |
29 continue | |
30 try: | |
31 builder_status = self.status.getBuilder(builder_name) | |
32 except KeyError: | |
33 log.msg('status.getBuilder(%r) failed' % builder_name) | |
34 continue | |
35 outcome = base.ITopBox(builder_status).getBox(request).class_ | |
36 lastbuild = 'LastBuild' | |
37 if outcome.startswith(lastbuild): | |
38 outcome = outcome[len(lastbuild):] | |
39 data['builders'].append({'outcome': outcome.strip(), | |
40 'name': builder_name}) | |
41 return data | |
OLD | NEW |