From 4738611bfd05b416c0e632b15dfebad2384e030d Mon Sep 17 00:00:00 2001 From: "Dustin J. Mitchell" Date: Sun, 14 Oct 2012 14:00:16 -0400 Subject: [PATCH] restore master.addBuildset, with deprecation warning --- master/buildbot/master.py | 48 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/master/buildbot/master.py b/master/buildbot/master.py index 058085353a1..99143c208b9 100644 --- a/master/buildbot/master.py +++ b/master/buildbot/master.py @@ -26,7 +26,7 @@ import buildbot import buildbot.pbmanager -from buildbot.util import datetime2epoch, ascii2unicode +from buildbot.util import epoch2datetime, datetime2epoch, ascii2unicode from buildbot.status.master import Status from buildbot.changes import changes from buildbot.changes.manager import ChangeManager @@ -42,6 +42,7 @@ from buildbot.process import metrics from buildbot.process import cache from buildbot.process.users.manager import UserManagerManager +from buildbot.status.results import SUCCESS, WARNINGS, FAILURE from buildbot import monkeypatches from buildbot import config @@ -407,6 +408,51 @@ def handle_deprec(oldname, newname): change = yield changes.Change.fromChdict(self, chdict) defer.returnValue(change) + @defer.inlineCallbacks + def addBuildset(self, scheduler, **kwargs): + log.msg("WARNING: master.addBuildset is deprecated; " + "use the data API update method") + bsid, brids = yield self.data.updates.addBuildset( + scheduler=scheduler, **kwargs) + defer.returnValue((bsid,brids)) + + @defer.inlineCallbacks + def maybeBuildsetComplete(self, bsid, _reactor=reactor): + """ + Instructs the master to check whether the buildset is complete, + and notify appropriately if it is. + + Note that buildset completions are only reported on the master + on which the last build request completes. + """ + brdicts = yield self.db.buildrequests.getBuildRequests( + bsid=bsid, complete=False) + + # if there are incomplete buildrequests, bail out + if brdicts: + return + + brdicts = yield self.db.buildrequests.getBuildRequests(bsid=bsid) + + # figure out the overall results of the buildset + cumulative_results = SUCCESS + for brdict in brdicts: + if brdict['results'] not in (SUCCESS, WARNINGS): + cumulative_results = FAILURE + + # mark it as completed in the database + complete_at_epoch = _reactor.seconds() + complete_at = epoch2datetime(complete_at_epoch) + yield self.db.buildsets.completeBuildset(bsid, cumulative_results, + complete_at=complete_at) + + # new-style notification + msg = dict( + bsid=bsid, + complete_at=complete_at_epoch, + results=cumulative_results) + self.mq.produce(('buildset', str(bsid), 'complete'), msg) + ## state maintenance (private)