Skip to content

Commit

Permalink
DRY
Browse files Browse the repository at this point in the history
  • Loading branch information
KATO Kazuyoshi committed Oct 8, 2009
1 parent 8b5cf83 commit a441263
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions buildbot/status/words.py
Expand Up @@ -306,16 +306,16 @@ def buildStarted(self, builderName, build):

self.send(r)

results_descriptions = {
SUCCESS: "Success",
WARNINGS: "Warnings",
FAILURE: "Failure",
EXCEPTION: "Exception",
}

def buildFinished(self, builderName, build, results):
builder = build.getBuilder()

results_descriptions = {
SUCCESS: "Success",
WARNINGS: "Warnings",
FAILURE: "Failure",
EXCEPTION: "Exception",
}

# only notify about builders we are interested in
log.msg('[Contact] builder %r in category %s finished' % (builder, builder.category))

Expand All @@ -328,34 +328,29 @@ def buildFinished(self, builderName, build, results):
r = "build #%d of %s is complete: %s" % \
(build.getNumber(),
builder.getName(),
results_descriptions.get(results, "??"))
self.results_descriptions.get(results, "??"))
r += " [%s]" % " ".join(build.getText())
buildurl = self.channel.status.getURLForThing(build)
if buildurl:
r += " Build details are at %s" % buildurl

if self.notify_for('finished') or self.notify_for(lower(results_descriptions.get(results))):
if self.notify_for('finished') or self.notify_for(lower(self.results_descriptions.get(results))):
self.send(r)
return

prevBuild = build.getPreviousBuild()
if prevBuild:
prevResult = prevBuild.getResults()

required_notification_control_string = join((lower(results_descriptions.get(prevResult)), \
required_notification_control_string = join((lower(self.results_descriptions.get(prevResult)), \
'To', \
capitalize(results_descriptions.get(results))), \
capitalize(self.results_descriptions.get(results))), \
'')

if (self.notify_for(required_notification_control_string)):
self.send(r)

def watchedBuildFinished(self, b):
results = {SUCCESS: "Success",
WARNINGS: "Warnings",
FAILURE: "Failure",
EXCEPTION: "Exception",
}

# only notify about builders we are interested in
builder = b.getBuilder()
Expand All @@ -368,7 +363,7 @@ def watchedBuildFinished(self, b):
r = "Hey! build %s #%d is complete: %s" % \
(b.getBuilder().getName(),
b.getNumber(),
results.get(b.getResults(), "??"))
self.results_descriptions.get(b.getResults(), "??"))
r += " [%s]" % " ".join(b.getText())
self.send(r)
buildurl = self.channel.status.getURLForThing(b)
Expand Down

0 comments on commit a441263

Please sign in to comment.