[Buildbot-devel] custom step - how to set when a step fail or pass (evaluateStat function?)

Dustin J. Mitchell dustin at v.igoro.us
Fri Mar 21 02:05:45 UTC 2014


I just spent a lot of brain cells trying to figure this stuff out
while working on "new-style steps" for nine.

There's no evaluateStat method to override - that method is a
brand-new method made up for that example, and called from the start
method.

You're right that self.finished(status) is the thing to call to
indicate that a step is finished successfully.

So I think you're on the right track, but you'll need the start method, too.

Perhaps I misunderstood the question, though.. did that help?

Dustin

On Thu, Mar 20, 2014 at 7:57 PM, shiny knight <theshinyknight at me.com> wrote:
> I am writing a custom class, derived by the shellcommand class.
>
> Basically I get my server data, which has info about how much a product has
> been enriched with various elements. I get the data file (which is a
> standard text file, tab delimited).
>
> Now, what I would like to obtain, is to have the step to fail when the data
> file contains certain values, and pass when has some other values. So far
> the docs didn't help me to figure out how to do so.
>
> Looking at the docs, I have an idea that there is a function to overwrite,
> that changes what results the step return....but I am basically shooting in
> the dark.
>
> I see in the customization.html page of the docs, an example that mention
> FAILURE and WARNINGS, for a property called self.finished. I assume that
> this is how you tell the Buildbot that something has to fail or raise a
> warning?
>
> The example show a snippet, where the check is done in a function called
> "evaluateStat (self, cmd)"
>
>     def evaluateStat(self, cmd):
>         if cmd.didFail():
>             self.step_status.setText(["File not found."])
>             self.finished(FAILURE)
>             return
>         s = cmd.updates["stat"][-1]
>         if not stat.S_ISDIR(s[stat.ST_MODE]):
>             self.step_status.setText(["'tis not a directory"])
>             self.finished(WARNINGS)
>             return
>
>         cmd = buildstep.RemoteCommand('glob', {'glob': self.dirname +
> '/*.pyc'})
>
>         d = self.runCommand(cmd)
>         d.addCallback(lambda res: self.evaluateGlob(cmd))
>         d.addErrback(self.failed)
>         return d
>
>
>
> So if I subclass shellcommand, and add evaluateStat(...) as described above,
> will this override the step original logic and allow me to dictate how to
> set self.finished for the Warning and Error state? I also don't get where
> "cmd" is declared, what it does and what is returning; but I assume that
> doesn't matter, since it is the self.finished() that set the step final
> state as pass, fail or warning. Does it matter where I put the call to
> self.finished()?
>
> I have already code that check the values, so all that I should do is to add
> in the if statements, the values that I want to use (unless I've got this
> wrong)
>
> I also assume that any other case non specified in that function will result
> in a "Pass" state, so you don't need to specify it.
>
> Am I on the right track, or did I got it wrong? I can't find anywhere an
> example that show how to change the pass/fail/warning state of a step, and a
> search on "evaluateStat" + buildbot on  google returns nothing.
>
> Thanks
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/13534_NeoTech
> _______________________________________________
> Buildbot-devel mailing list
> Buildbot-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/buildbot-devel
>




More information about the devel mailing list