[Buildbot-commits] buildbot/buildbot/process base.py, 1.73, 1.74 buildstep.py, 1.5, 1.6 factory.py, 1.15, 1.16
Brian Warner
warner at users.sourceforge.net
Mon Jun 18 02:52:51 UTC 2007
- Previous message (by thread): [Buildbot-commits] buildbot ChangeLog,1.854,1.855
- Next message (by thread): [Buildbot-commits] buildbot/buildbot/steps dummy.py, 1.4, 1.5 maxq.py, 1.1, 1.2 python_twisted.py, 1.3, 1.4 shell.py, 1.4, 1.5 source.py, 1.5, 1.6 transfer.py, 1.10, 1.11
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/buildbot/buildbot/buildbot/process
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv23618/buildbot/process
Modified Files:
base.py buildstep.py factory.py
Log Message:
[project @ use instances instead of class/kwarg tuples when putting BuildSteps in factories. Closes: #11.]
Original author: warner at lothar.com
Date: 2007-06-18 02:51:00+00:00
Index: base.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/process/base.py,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- base.py 11 Dec 2006 09:06:34 -0000 1.73
+++ base.py 18 Jun 2007 02:52:49 -0000 1.74
@@ -237,16 +237,14 @@
# consider sorting these by number
return changetext
- def setSteps(self, steps):
- """Set a list of StepFactories, which are generally just class
- objects which derive from step.BuildStep . These are used to create
- the Steps themselves when the Build starts (as opposed to when it is
- first created). By creating the steps later, their __init__ method
- will have access to things like build.allFiles() ."""
- self.stepFactories = steps # tuples of (factory, kwargs)
- for s in steps:
- pass
-
+ def setStepFactories(self, step_factories):
+ """Set a list of 'step factories', which are tuples of (class,
+ kwargs), where 'class' is generally a subclass of step.BuildStep .
+ These are used to create the Steps themselves when the Build starts
+ (as opposed to when it is first created). By creating the steps
+ later, their __init__ method will have access to things like
+ build.allFiles() ."""
+ self.stepFactories = list(step_factories)
@@ -349,14 +347,14 @@
for factory, args in self.stepFactories:
args = args.copy()
- if not args.has_key("workdir"):
- args['workdir'] = self.workdir
try:
- step = factory(build=self, **args)
+ step = factory(**args)
except:
log.msg("error while creating step, factory=%s, args=%s"
% (factory, args))
raise
+ step.setBuild(self)
+ step.setDefaultWorkdir(self.workdir)
name = step.name
count = 1
while name in stepnames and count < 100:
Index: buildstep.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/process/buildstep.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- buildstep.py 12 Dec 2006 03:24:03 -0000 1.5
+++ buildstep.py 18 Jun 2007 02:52:49 -0000 1.6
@@ -546,7 +546,7 @@
# arguments to the RemoteShellCommand that it creates). Such delegating
# subclasses will use this list to figure out which arguments are meant
# for us and which should be given to someone else.
- parms = ['build', 'name', 'locks',
+ parms = ['name', 'locks',
'haltOnFailure',
'flunkOnWarnings',
'flunkOnFailure',
@@ -563,23 +563,40 @@
step_status = None
progress = None
- def __init__(self, build, **kwargs):
- self.build = build
+ def __init__(self, **kwargs):
+ self.factory = (self.__class__, dict(kwargs))
for p in self.__class__.parms:
if kwargs.has_key(p):
setattr(self, p, kwargs[p])
del kwargs[p]
- # we want to encourage all steps to get a workdir, so tolerate its
- # presence here. It really only matters for non-ShellCommand steps
- # like Dummy
- if kwargs.has_key('workdir'):
- del kwargs['workdir']
if kwargs:
why = "%s.__init__ got unexpected keyword argument(s) %s" \
% (self, kwargs.keys())
raise TypeError(why)
self._pendingLogObservers = []
+ def setBuild(self, build):
+ # subclasses which wish to base their behavior upon qualities of the
+ # Build (e.g. use the list of changed files to run unit tests only on
+ # code which has been modified) should do so here. The Build is not
+ # available during __init__, but setBuild() will be called just
+ # afterwards.
+ self.build = build
+
+ def setDefaultWorkdir(self, workdir):
+ # the Build calls this just after __init__ and setDefaultWorkdir.
+ # ShellCommand and variants use a slave-side workdir, but some other
+ # steps do not. Subclasses which use a workdir should use the value
+ # set by this method unless they were constructed with something more
+ # specific.
+ pass
+
+ def addFactoryArguments(self, **kwargs):
+ self.factory[1].update(kwargs)
+
+ def getStepFactory(self):
+ return self.factory
+
def setStepStatus(self, step_status):
self.step_status = step_status
@@ -895,6 +912,7 @@
def __init__(self, logfiles={}, *args, **kwargs):
BuildStep.__init__(self, *args, **kwargs)
+ self.addFactoryArguments(logfiles=logfiles)
# merge a class-level 'logfiles' attribute with one passed in as an
# argument
self.logfiles = self.logfiles.copy()
Index: factory.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/process/factory.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- factory.py 17 Sep 2006 20:35:49 -0000 1.15
+++ factory.py 18 Jun 2007 02:52:49 -0000 1.16
@@ -24,7 +24,12 @@
def __init__(self, steps=None):
if steps is None:
steps = []
- self.steps = steps
+ self.steps = [self._makeStepFactory(s) for s in steps]
+
+ def _makeStepFactory(self, step_or_factory):
+ if isinstance(step_or_factory, BuildStep):
+ return step_or_factory.getStepFactory()
+ return step_or_factory
def newBuild(self, request):
"""Create a new Build instance.
@@ -32,11 +37,15 @@
"""
b = self.buildClass(request)
b.useProgress = self.useProgress
- b.setSteps(self.steps)
+ b.setStepFactories(self.steps)
return b
- def addStep(self, steptype, **kwargs):
- self.steps.append((steptype, kwargs))
+ def addStep(self, step_or_factory, **kwargs):
+ if isinstance(step_or_factory, BuildStep):
+ s = step_or_factory.getStepFactory()
+ else:
+ s = (step_or_factory, dict(kwargs))
+ self.steps.append(s)
# BuildFactory subclasses for common build tools
- Previous message (by thread): [Buildbot-commits] buildbot ChangeLog,1.854,1.855
- Next message (by thread): [Buildbot-commits] buildbot/buildbot/steps dummy.py, 1.4, 1.5 maxq.py, 1.1, 1.2 python_twisted.py, 1.3, 1.4 shell.py, 1.4, 1.5 source.py, 1.5, 1.6 transfer.py, 1.10, 1.11
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Commits
mailing list