From f43143835cba3ca5963e07874da17c1416a031c2 Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Wed, 28 Jan 2009 08:34:04 -0800 Subject: [PATCH] Refactored try buildName validation for reuse. --- buildbot/scheduler.py | 53 ++++++++++++++++++++++----------------------------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/buildbot/scheduler.py b/buildbot/scheduler.py index 630b5c9..b23c5ee 100644 --- a/buildbot/scheduler.py +++ b/buildbot/scheduler.py @@ -578,6 +578,21 @@ class TryBase(BaseScheduler): # Try schedulers ignore Changes pass + def processBuilderList(self, builderNames): + # self.builderNames is the configured list of builders + # available for try. If the user supplies a list of builders, + # it must be restricted to the configured list. If not, build + # on all of the configured builders. + if builderNames: + for b in builderNames: + if not b in self.builderNames: + log.msg("%s got with builder %s" % (self, b)) + log.msg(" but that wasn't in our list: %s" + % (self.builderNames,)) + return [] + else: + builderNames = self.builderNames + return builderNames class BadJobfile(Exception): pass @@ -660,21 +675,10 @@ class Try_Jobdir(TryBase): log.msg("%s reports a bad jobfile in %s" % (self, filename)) log.err() return - # self.builderNames is the configured list of builders - # available for try. If the user supplies a list of builders, - # it must be restricted to the configured list. If not, build - # on all of the configured builders. - if builderNames: - for b in builderNames: - if not b in self.builderNames: - log.msg("%s got jobfile %s with builder %s" % (self, - filename, b)) - log.msg(" but that wasn't in our list: %s" - % (self.builderNames,)) - return - else: - builderNames = self.builderNames - + # Validate/fixup the builder names. + builderNames = self.processBuilderList(builderNames) + if not builderNames: + return reason = "'try' job" bs = buildset.BuildSet(builderNames, ss, reason=reason, bsid=bsid, properties=self.properties) @@ -718,21 +722,10 @@ class Try_Userpass_Perspective(pbutil.NewCredPerspective): def perspective_try(self, branch, revision, patch, builderNames, properties={}): log.msg("user %s requesting build on builders %s" % (self.username, builderNames)) - # self.builderNames is the configured list of builders - # available for try. If the user supplies a list of builders, - # it must be restricted to the configured list. If not, build - # on all of the configured builders. - # TODO: This code should be refactored as it's almost identical - # to the ssh case. - if builderNames: - for b in builderNames: - if not b in self.parent.builderNames: - log.msg("%s got job with builder %s" % (self, b)) - log.msg(" but that wasn't in our list: %s" - % (self.parent.builderNames,)) - return - else: - builderNames = self.parent.builderNames + # Validate/fixup the builder names. + builderNames = self.parent.processBuilderList(builderNames) + if not builderNames: + return ss = SourceStamp(branch, revision, patch) reason = "'try' job from user %s" % self.username -- 2.11.4.GIT