[Buildbot-devel] doStepIf function
Charles Lepple
clepple at gmail.com
Mon May 10 13:01:29 UTC 2010
On May 10, 2010, at 8:33 AM, robert dugal wrote:
> I cannot figure out the syntax for how to use doStepIf with a
> function so that the step is only executed if certain conditions are
> true. The condition needs to have some complex testing of builder
> properties so I want to write this as a function.
> How do I convert something like this below into using a function?
>
> self.addStep(ShellCommand(
> doStepIf=(
> (lambda(step):
> step.build.getProperties().has_key("FOO"))
> and
> (lambda(step): step.getProperty("FOO") in fooList)
> ), command='some command'))
Something like this:
#########
def do_step_test(step):
return step.build.getProperties().has_key("FOO") and
step.getProperty("FOO") in fooList
self.addStep(ShellCommand(
doStepIf = do_step_test,
command = 'some command')
#########
To make that work with lambda functions, I think you would need to put
the "and" inside a single lambda expression. The boolean "and" of two
function definitions won't get you what you want (not to be confused
with the *results* of two functions, "and"ed together).
http://docs.python.org/tutorial/controlflow.html#lambda-forms
More information about the devel
mailing list