1 # Copyright 2015 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 common.buildbot import step 6 7 8 class Build(object): 9 10 def __init__(self, data, builder_url): 11 self._number = data['number'] 12 self._slave_name = data['slave'] 13 self._status = data['results'] 14 self._start_time, self._end_time = data['times'] 15 self._url = '%s/builds/%d' % (builder_url, self._number) 16 17 source_stamp = data['sourceStamp'] 18 if 'revision' in source_stamp: 19 self._revision = source_stamp['revision'] 20 if 'changes' in source_stamp and source_stamp['changes']: 21 self._revision_time = data['sourceStamp']['changes'][-1]['when'] 22 23 self._steps = tuple(step.Step(step_data, self._url) 24 for step_data in data['steps']) 25 26 def __lt__(self, other): 27 return self.number < other.number 28 29 def __str__(self): 30 return str(self.number) 31 32 @property 33 def number(self): 34 return self._number 35 36 @property 37 def url(self): 38 return self._url 39 40 @property 41 def slave_name(self): 42 return self._slave_name 43 44 @property 45 def status(self): 46 return self._status 47 48 @property 49 def complete(self): 50 return self.status is not None 51 52 @property 53 def revision(self): 54 return self._revision 55 56 @property 57 def revision_time(self): 58 """The time the revision was committed. 59 60 Warning: this field may not be populated. 61 """ 62 return self._revision_time 63 64 @property 65 def start_time(self): 66 return self._start_time 67 68 @property 69 def end_time(self): 70 return self._end_time 71 72 @property 73 def steps(self): 74 return self._steps 75