| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import base64 | 5 import base64 |
| 6 import collections | 6 import collections |
| 7 import datetime | 7 import datetime |
| 8 import functools | 8 import functools |
| 9 import json | 9 import json |
| 10 import os | 10 import os |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 for builder_name in self._status.getBuilderNames()} | 369 for builder_name in self._status.getBuilderNames()} |
| 370 builder_infos = {} | 370 builder_infos = {} |
| 371 for name, builder in builders.iteritems(): | 371 for name, builder in builders.iteritems(): |
| 372 # This requires a deferred call since the data is queried from | 372 # This requires a deferred call since the data is queried from |
| 373 # the postgres DB (sigh). | 373 # the postgres DB (sigh). |
| 374 pending = yield builder.getPendingBuildRequestStatuses() | 374 pending = yield builder.getPendingBuildRequestStatuses() |
| 375 # Optimization cheat: only get the first 75 pending builds. | 375 # Optimization cheat: only get the first 75 pending builds. |
| 376 # This caps the amount of postgres db calls for really out of | 376 # This caps the amount of postgres db calls for really out of |
| 377 # control builders | 377 # control builders |
| 378 pending = pending[:75] | 378 pending = pending[:75] |
| 379 pendingStatues = yield defer.DeferredList( | 379 pendingStates = yield defer.DeferredList( |
| 380 [p.asDict_async() for p in pending]) | 380 [p.asDict_async() for p in pending]) |
| 381 # Not included: basedir, cachedBuilds. | 381 # Not included: basedir, cachedBuilds. |
| 382 # cachedBuilds isn't useful and takes a ton of resources to compute. | 382 # cachedBuilds isn't useful and takes a ton of resources to compute. |
| 383 builder_info = { | 383 builder_info = { |
| 384 'slaves': builder.slavenames, | 384 'slaves': builder.slavenames, |
| 385 'currentBuilds': sorted(b.getNumber() for b in builder.currentBuilds), | 385 'currentBuilds': sorted(b.getNumber() for b in builder.currentBuilds), |
| 386 'pendingBuilds': len(pending), | 386 'pendingBuilds': len(pending), |
| 387 'pendingBuildStatues': pendingStatues, | 387 # p is a tuple of (success, payload) |
| 388 'pendingBuildStates': [p[1] for p in pendingStates if p[0]], |
| 388 'state': builder.getState()[0], | 389 'state': builder.getState()[0], |
| 389 'category': builder.category, | 390 'category': builder.category, |
| 390 } | 391 } |
| 391 builder_infos[name] = builder_info | 392 builder_infos[name] = builder_info |
| 392 | 393 |
| 393 slaves = {slave_name: self._status.getSlave(slave_name).asDict() | 394 slaves = {slave_name: self._status.getSlave(slave_name).asDict() |
| 394 for slave_name in self._status.getSlaveNames()} | 395 for slave_name in self._status.getSlaveNames()} |
| 395 defer.returnValue({ | 396 defer.returnValue({ |
| 396 'builders': builder_infos, 'slaves': slaves, 'name': self.name}) | 397 'builders': builder_infos, 'slaves': slaves, 'name': self.name}) |
| 397 | 398 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 422 return self | 423 return self |
| 423 | 424 |
| 424 @event_handler | 425 @event_handler |
| 425 def stepStarted(self, build, _step): | 426 def stepStarted(self, build, _step): |
| 426 # This info is included in the master json. | 427 # This info is included in the master json. |
| 427 return self | 428 return self |
| 428 | 429 |
| 429 @event_handler | 430 @event_handler |
| 430 def buildFinished(self, _builderName, build, _results): | 431 def buildFinished(self, _builderName, build, _results): |
| 431 self._recordBuild(build) | 432 self._recordBuild(build) |
| OLD | NEW |