2 from twisted
.python
import log
3 from twisted
.web
import xmlrpc
4 from buildbot
.status
.builder
import Results
5 from itertools
import count
7 class XMLRPCServer(xmlrpc
.XMLRPC
):
9 xmlrpc
.XMLRPC
.__init
__(self
)
11 def render(self
, req
):
12 # extract the IStatus and IControl objects for later use, since they
13 # come from the request object. They'll be the same each time, but
14 # they aren't available until the first request arrives.
15 self
.status
= req
.site
.buildbot_service
.getStatus()
16 self
.control
= req
.site
.buildbot_service
.getControl()
17 return xmlrpc
.XMLRPC
.render(self
, req
)
19 def xmlrpc_getAllBuildsInInterval(self
, start
, stop
):
20 """Return a list of builds that have completed after the 'start'
21 timestamp and before the 'stop' timestamp. This looks at all
24 The timestamps are integers, interpreted as standard unix timestamps
25 (seconds since epoch).
27 Each Build is returned as a tuple in the form::
28 (buildername, buildnumber, build_end, branchname, revision,
31 The buildnumber is an integer. 'build_end' is an integer (seconds
32 since epoch) specifying when the build finished.
34 The branchname is a string, which may be an empty string to indicate
35 None (i.e. the default branch). The revision is a string whose
36 meaning is specific to the VC system in use, and comes from the
37 'got_revision' build property. The results are expressed as a string,
38 one of ('success', 'warnings', 'failure', 'exception'). The text is a
39 list of short strings that ought to be joined by spaces and include
40 slightly more data about the results of the build.
42 #log.msg("start: %s %s %s" % (start, type(start), start.__class__))
43 log
.msg("getAllBuildsInInterval: %d - %d" % (start
, stop
))
46 for builder_name
in self
.status
.getBuilderNames():
47 builder
= self
.status
.getBuilder(builder_name
)
48 for build_number
in count(1):
49 build
= builder
.getBuild(-build_number
)
52 if not build
.isFinished():
54 (build_start
, build_end
) = build
.getTimes()
55 # in reality, builds are mostly ordered by start time. For
56 # the purposes of this method, we pretend that they are
57 # strictly ordered by end time, so that we can stop searching
58 # when we start seeing builds that are outside the window.
60 continue # keep looking
64 ss
= build
.getSourceStamp()
69 revision
= build
.getProperty("got_revision")
74 answer
= (builder_name
,
79 Results
[build
.getResults()],
82 all_builds
.append((build_end
, answer
))
83 # we've gotten all the builds that we care about from this
84 # particular builder, so now we can continue on the next builder
86 # now we've gotten all the builds we're interested in. Sort them by
88 all_builds
.sort(lambda a
,b
: cmp(a
[0], b
[0]))
89 # and remove the timestamps
90 all_builds
= [t
[1] for t
in all_builds
]
92 log
.msg("ready to go: %s" % (all_builds
,))
96 def xmlrpc_getBuild(self
, builder_name
, build_number
):
97 """Return information about a specific build.
100 builder
= self
.status
.getBuilder(builder_name
)
101 build
= builder
.getBuild(build_number
)
103 info
['builder_name'] = builder
.getName()
104 info
['url'] = self
.status
.getURLForThing(build
)
105 info
['reason'] = build
.getReason()
106 info
['slavename'] = build
.getSlavename()
107 info
['results'] = build
.getResults()
108 info
['text'] = build
.getText()
109 ss
= build
.getSourceStamp()
110 info
['start'], info
['end'] = build
.getTimes()
113 for s
in build
.getSteps():
115 stepinfo
['name'] = s
.getName()
116 stepinfo
['start'], stepinfo
['end'] = s
.getTimes()
117 stepinfo
['results'] = s
.getResults()
118 info_steps
.append(stepinfo
)
119 info
['steps'] = info_steps
122 for l
in build
.getLogs():
124 loginfo
['name'] = l
.getStep().getName() + "/" + l
.getName()
125 #loginfo['text'] = l.getText()
126 loginfo
['text'] = "HUGE"
127 info_logs
.append(loginfo
)
128 info
['logs'] = info_logs