[Buildbot-commits] buildbot/buildbot/process base.py, 1.81, 1.82 builder.py, 1.53, 1.54 properties.py, 1.2, 1.3
Brian Warner
warner at users.sourceforge.net
Thu May 22 22:13:08 UTC 2008
Update of /cvsroot/buildbot/buildbot/buildbot/process
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17543/buildbot/process
Modified Files:
base.py builder.py properties.py
Log Message:
[project @ #124:scheduler-properties.patch]
Arrange for properties to come down from schedulers, via BuildStep and
BuildRequest objects. custom_props are still present, in parallel, but
will go eventually. Triggered builds no longer propagate custom props.
Original author: dustin at v.igoro.us
Date: 2008-04-12 23:46:58+00:00
Index: base.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/process/base.py,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -d -r1.81 -r1.82
--- base.py 22 May 2008 22:12:57 -0000 1.81
+++ base.py 22 May 2008 22:13:06 -0000 1.82
@@ -11,6 +11,7 @@
from buildbot.status.builder import SUCCESS, WARNINGS, FAILURE, EXCEPTION
from buildbot.status.builder import Results, BuildRequestStatus
from buildbot.status.progress import BuildProgress
+from buildbot.process.properties import Properties
class BuildRequest:
"""I represent a request to a specific Builder to run a single build.
@@ -39,8 +40,8 @@
provide this, but for forced builds the user requesting the
build will provide a string.
- @type custom_props: dictionary.
- @ivar custom_props: custom user properties.
+ @type properties: Properties object
+ @ivar properties: properties that should be applied to this build
@ivar status: the IBuildStatus object which tracks our status
@@ -56,18 +57,18 @@
implements(interfaces.IBuildRequestControl)
- def __init__(self, reason, source, builderName=None, scheduler=None, custom_props=None):
+ def __init__(self, reason, source, builderName=None, custom_props=None, properties=None):
# TODO: remove the =None on builderName, it is there so I don't have
# to change a lot of tests that create BuildRequest objects
assert interfaces.ISourceStamp(source, None)
self.reason = reason
self.source = source
- self.scheduler = scheduler
- if not custom_props: custom_props = {}
- self.custom_props = custom_props
- assert isinstance(self.custom_props, dict), \
- "custom_props must be a dict (not %r)" % (self.custom_props,)
+ self.properties = Properties()
+ if properties:
+ self.properties.updateFromProperties(properties)
+ if custom_props:
+ self.properties.update(custom_props, "BuildRequest-custom_props")
self.start_watchers = []
self.finish_watchers = []
@@ -182,12 +183,6 @@
# build a source stamp
self.source = requests[0].mergeWith(requests[1:])
self.reason = requests[0].mergeReasons(requests[1:])
- self.scheduler = requests[0].scheduler
-
- # Set custom properties.
- self.custom_properties = requests[0].customProps()
-
- #self.abandoned = False
self.progress = None
self.currentStep = None
@@ -213,14 +208,11 @@
properties can live."""
self.build_status.setProperty(propname, value, source)
- def getCustomProperties(self):
- return self.custom_properties
-
def getProperties(self):
return self.build_status.getProperties()
def getProperty(self, propname):
- return self.build_status.properties[propname]
+ return self.build_status.getProperty(propname)
def allChanges(self):
return self.source.changes
@@ -278,24 +270,33 @@
def getSlaveName(self):
return self.slavebuilder.slave.slavename
- def setupStatus(self, build_status):
- self.build_status = build_status
- self.setProperty("buildername", self.builder.name, "build")
- self.setProperty("buildnumber", self.build_status.number, "build")
- self.setProperty("branch", self.source.branch, "build")
- self.setProperty("revision", self.source.revision, "build")
- if self.scheduler is None:
- self.setProperty("scheduler", "none", "build")
- else:
- self.setProperty("scheduler", self.scheduler.name, "build")
- for key, userProp in self.custom_properties.items():
- self.setProperty(key, userProp, "custom_props")
+ def setupProperties(self):
+ props = self.getProperties()
+
+ #props.updateFromProperties(self.global_properties) TODO
+
+ # get any properties from requests (this is the path through
+ # which schedulers will send us properties)
+ for rq in self.requests:
+ props.updateFromProperties(rq.properties)
+
+ # now set some properties of our own, corresponding to the
+ # build itself
+ props.setProperty("buildername", self.builder.name, "Build")
+ props.setProperty("buildnumber", self.build_status.number, "Build")
+ props.setProperty("branch", self.source.branch, "Build")
+ props.setProperty("revision", self.source.revision, "Build")
def setupSlaveBuilder(self, slavebuilder):
self.slavebuilder = slavebuilder
+
+ # navigate our way back to the L{buildbot.buildslave.BuildSlave}
+ # object that came from the config, and get its properties
+ buildslave_properties = slavebuilder.slave.properties
+ self.getProperties().updateFromProperties(buildslave_properties)
+
self.slavename = slavebuilder.slave.slavename
self.build_status.setSlavename(self.slavename)
- self.setProperty("slavename", self.slavename, "build")
def startBuild(self, build_status, expectations, slavebuilder):
"""This method sets up the build, then starts it by invoking the
@@ -308,8 +309,9 @@
# the Deferred returned by this method.
log.msg("%s.startBuild" % self)
- self.setupStatus(build_status)
+ self.build_status = build_status
# now that we have a build_status, we can set properties
+ self.setupProperties()
self.setupSlaveBuilder(slavebuilder)
# convert all locks into their real forms
Index: builder.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/process/builder.py,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- builder.py 23 Mar 2008 03:14:47 -0000 1.53
+++ builder.py 22 May 2008 22:13:06 -0000 1.54
@@ -253,6 +253,8 @@
@type building: list of L{buildbot.process.base.Build}
@ivar building: Builds that are actively running
+ @type slaves: list of L{buildbot.buildslave.BuildSlave} objects
+ @ivar slaves: the slaves currently available for building
"""
expectations = None # this is created the first time we get a good build
@@ -445,7 +447,7 @@
"""This is invoked by the BuildSlave when the self.slavename bot
registers their builder.
- @type slave: L{buildbot.master.BuildSlave}
+ @type slave: L{buildbot.buildslave.BuildSlave}
@param slave: the BuildSlave that represents the buildslave as a whole
@type remote: L{twisted.spread.pb.RemoteReference}
@param remote: a reference to the L{buildbot.slave.bot.SlaveBuilder}
Index: properties.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/process/properties.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- properties.py 22 May 2008 22:13:02 -0000 1.2
+++ properties.py 22 May 2008 22:13:06 -0000 1.3
@@ -18,8 +18,13 @@
As a special case, a property value of None is returned as an empty
string when used as a mapping.
"""
- def __init__(self):
+ def __init__(self, props={}, props_source=''):
+ """
+ @param props: dictionary giving initial property values (for testing)
+ @param props_source: source to use for props
+ """
self.properties = {}
+ if props: self.update(props, props_source)
def __getitem__(self, name):
"""Just get the value for this property, special-casing None -> ''"""
@@ -37,6 +42,9 @@
def getPropertySource(self, name):
return self.properties[name][1]
+ def __repr__(self):
+ return repr(dict([ (k,v[0]) for k,v in self.properties.iteritems() ]))
+
def setProperty(self, name, value, source):
self.properties[name] = (value, source)
More information about the Commits
mailing list