Skip to content

Commit

Permalink
Merge commit '0fc76a1fca3603a1ac91d5c62eb4ab01a96b6126' into jinja
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-sonestedt committed Dec 13, 2009
2 parents 64a06f1 + 0fc76a1 commit ce3e242
Showing 1 changed file with 40 additions and 8 deletions.
48 changes: 40 additions & 8 deletions buildbot/status/web/xmlrpc.py
Expand Up @@ -27,6 +27,17 @@ def xmlrpc_getLastBuildResults(self, builder_name):
builder = self.status.getBuilder(builder_name)
lastbuild = builder.getBuild(-1)
return Results[lastbuild.getResults()]

def xmlrpc_getAllLastBuilds(self, num_builds):
"""Return the last N completed builds for all builders.
'num_builds' is the number of builds to return
"""
all_builds = []
for name in self.status.getBuilderNames():
all_builds.extend(self.xmlrpc_getLastBuilds(name, num_builds))
return all_builds

def xmlrpc_getLastBuilds(self, builder_name, num_builds):
"""Return the last N completed builds for the given builder.
Expand All @@ -38,10 +49,8 @@ def xmlrpc_getLastBuilds(self, builder_name, num_builds):
log.msg("getLastBuilds: %s - %d" % (builder_name, num_builds))
builder = self.status.getBuilder(builder_name)
all_builds = []
build_number = 1
while len(all_builds) < num_builds:
for build_number in range(1, num_builds+1):
build = builder.getBuild(-build_number)
build_number += 1
if not build:
break
if not build.isFinished():
Expand All @@ -57,14 +66,26 @@ def xmlrpc_getLastBuilds(self, builder_name, num_builds):
except KeyError:
revision = ""
revision = str(revision)


result = Results[build.getResults()]
if result == 'failure':
fail_names = result = build.getText()[1:]
reasons = []
for s in build.getSteps():
if s.getName() in fail_names:
reasons.append(s.getText())
else:
result = build.getText()
reasons = []
answer = (builder_name,
build.getNumber(),
build_start,
build_end,
branch,
revision,
Results[build.getResults()],
build.getText(),
result,
reasons,
)
all_builds.append((build_end, answer))

Expand Down Expand Up @@ -169,6 +190,7 @@ def xmlrpc_getBuild(self, builder_name, build_number):
info['slavename'] = build.getSlavename()
info['results'] = build.getResults()
info['text'] = build.getText()
info['reasons'] = []
# Added to help out requests for build -N
info['number'] = build.number
ss = build.getSourceStamp()
Expand All @@ -182,23 +204,33 @@ def xmlrpc_getBuild(self, builder_name, build_number):
revision = ""
info['revision'] = str(revision)
info['start'], info['end'] = build.getTimes()


step_names = {}

info_steps = []
for s in build.getSteps():
stepinfo = {}
stepinfo['name'] = s.getName()
stepinfo['start'], stepinfo['end'] = s.getTimes()
stepinfo['results'] = s.getResults()
stepinfo['text'] = s.getText()
info_steps.append(stepinfo)
if info['text'][0] == 'failed' and stepinfo['name'] in info['text']:
info['reasons'].append(stepinfo['text'])
step_names[stepinfo['name']] = stepinfo
info['steps'] = info_steps

info_logs = []
info['full_error'] = {}
for l in build.getLogs():
loginfo = {}
loginfo['name'] = l.getStep().getName() + "/" + l.getName()
name = l.getStep().getName()
loginfo['name'] = name + "/" + l.getName()
#loginfo['text'] = l.getText()
loginfo['text'] = "HUGE"
if step_names.get(name):
if step_names[name]['text'][-1] == 'failed':
info['full_error'][name] = l.getText()
info_logs.append(loginfo)
info['logs'] = info_logs
return info

0 comments on commit ce3e242

Please sign in to comment.