1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 from zope.interface import implements
17 from twisted.python import log
18 from twisted.internet import defer
19 from buildbot import interfaces
20 from buildbot.util.eventual import eventually
23 implements(interfaces.IBuildRequestStatus)
24
25 - def __init__(self, buildername, brid, status):
26 self.buildername = buildername
27 self.brid = brid
28 self.status = status
29 self.master = status.master
30
31 self._buildrequest = None
32 self._buildrequest_lock = defer.DeferredLock()
33
34 @defer.deferredGenerator
36 """
37 Get the underlying BuildRequest object for this status. This is a slow
38 operation!
39
40 @returns: BuildRequest instance or None, via Deferred
41 """
42
43 from buildbot.process import buildrequest
44
45
46 if self._buildrequest:
47 yield self._buildrequest
48
49 wfd = defer.waitForDeferred(
50 self._buildrequest_lock.acquire())
51 yield wfd
52 wfd.getResult()
53
54 try:
55 if not self._buildrequest:
56 wfd = defer.waitForDeferred(
57 self.master.db.buildrequests.getBuildRequest(self.brid))
58 yield wfd
59 brd = wfd.getResult()
60
61 wfd = defer.waitForDeferred(
62 buildrequest.BuildRequest.fromBrdict(self.master, brd))
63 yield wfd
64 self._buildrequest = wfd.getResult()
65 except:
66 self._buildrequest_lock.release()
67 raise
68
69 self._buildrequest_lock.release()
70
71 yield self._buildrequest
72
76
77
78 @defer.deferredGenerator
80 wfd = defer.waitForDeferred(
81 self._getBuildRequest())
82 yield wfd
83 br = wfd.getResult()
84
85 yield br.bsid
86
87 @defer.deferredGenerator
89 wfd = defer.waitForDeferred(
90 self._getBuildRequest())
91 yield wfd
92 br = wfd.getResult()
93
94 yield br.source
95
97 return self.buildername
98
99 @defer.deferredGenerator
116
118 d = self.getBuilds()
119 def notify_old(oldbuilds):
120 for bs in oldbuilds:
121 eventually(observer, bs)
122 d.addCallback(notify_old)
123 d.addCallback(lambda _ :
124 self.status._buildrequest_subscribe(self.brid, observer))
125 d.addErrback(log.err, 'while notifying subscribers')
126
128 self.status._buildrequest_unsubscribe(self.brid, observer)
129
130 @defer.deferredGenerator
132 wfd = defer.waitForDeferred(
133 self._getBuildRequest())
134 yield wfd
135 br = wfd.getResult()
136
137 yield br.submittedAt
138
140 result = {}
141
142 result['source'] = None
143 result['builderName'] = self.buildername
144 result['submittedAt'] = None
145
146
147 result['builds'] = []
148 return result
149
150 @defer.deferredGenerator
152 result = {}
153
154 wfd = defer.waitForDeferred(
155 self.getSourceStamp())
156 yield wfd
157 ss = wfd.getResult()
158 result['source'] = ss.asDict()
159
160 result['builderName'] = self.getBuilderName()
161
162 wfd = defer.waitForDeferred(
163 self.getSubmitTime())
164 yield wfd
165 submittedAt = wfd.getResult()
166 result['submittedAt'] = submittedAt
167
168 wfd = defer.waitForDeferred(
169 self.getBuilds())
170 yield wfd
171 builds = wfd.getResult()
172
173 result['builds'] = [ build.asDict() for build in builds ]
174
175 yield result
176