[Buildbot-devel] custom step - how to set when a step fail or pass (evaluateStat function?)
shiny knight
theshinyknight at me.com
Fri Mar 21 04:35:38 UTC 2014
It did Dustin !
I was just banging my head trying to find exactly where is the entry point to change the result, and I was following the Results class; which is the wrong way. Then I was checking the customization section for another question, and found that example that sparkled the idea. Your post made it clearer.
I was assuming that there was a function to override, like you do with createSummary, so you can customize how the logs output on the page (of course you need to call self.addCompleteLog() or it won't show on the page); that's why I thought that evaluateStats was that function.
So in the init you call super constructor (sorry, not sure how you say it in Python), and then add in start the statement, that include the self.finished based on a per case basis? Something like that?
class myclass(shellcommand):
def __init__(self, *kwargs):
**my class init stuff **
ShellCommand.__init__(self. **kwargs)
def start(self):
** implementation of the class here **
if X > 10:
self.finished(WARNING)
return
else if X < 10:
self.finished(FAILURE)
return
def createSummary(self, log):
** do stuff with the logs **
So is this about to change? From your comment it seems that you are working on a new step class?
On Mar 20, 2014, at 7:05 PM, Dustin J. Mitchell <dustin at v.igoro.us> wrote:
> 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
>>
>
> ------------------------------------------------------------------------------
> 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