[Buildbot-devel] withproperties or interpolate in ShellCommand

Vasily vasslitvinov at pisem.net
Fri Sep 5 15:16:13 UTC 2014


Hi again,

The class to make synchronous call I've implemented is below:

from twisted.internet import defer
from buildbot.process.properties import Properties

class RenderPropertiesSync(object):
    def __init__(self, properties, value):
        self.properties = properties
        self.value = value

    @defer.inlineCallbacks
    def renderSync(self):
        self.result = yield self.properties.render(self.value)

    def __call__(self):
        self.renderSync()
        try:
            return self.result
        except AttributeError:
            raise ValueError("Bad value supplied - cannot substitute
properties in it")

And to get the value of a WithProperties() stuff you do this:

def patch():
    oldPropertiesRender = Properties.render
    def newPropertiesRender(self, value, sync = False):
        if sync:
            return RenderPropertiesSync(self, value)()
        else:
            return oldPropertiesRender(self, value)
    Properties.render = newPropertiesRender

patch()

This adds second parameter to self.render(), returning back ability to do
synchronous properties call.

Thanks,
Vasily


2014-09-05 13:20 GMT+04:00 Vasily <vasslitvinov at pisem.net>:

> Hi,
>
> I recall they changed the behavior either at 0.8.5 or 0.8.7 - prior to
> that change WithProperties call (and call to self.render) was synchronous,
> and all worked okay, but in latest code both are asynchronous, so it isn't
> easy to get the same result.
>
> I have a piece of code that does synchronous substitution of the
> properties, but I'll be able to post it later - right now I'm writing this
> from my cell phone, and the piece is on my laptop. I'll try to post it
> sometime later if you need it, but it is probably better to embrace new
> logic and use "renderables" field (see ShellCommand implementation for the
> example).
>
> Thanks,
> Vasily
> 05 сент. 2014 г. 12:29 пользователь "Jürgen Schulz-Brüssel" <
> juergen.schulz-bruessel at thinkproject.com> написал:
>
>
> sorry of getting back on this so late.
>
> > I'm surprised that you got an error about Interpolate when you were
> > using WithProperties.
>
> that was obviously misunderstanding. I used to use WithProperties and
> tried Interpolate as well (after upgrading), with the same result.
>
> > I see that you were calling 'self.render', which suggests that this
> > 'self.command = ' is not in the step's constructor, but in some method
> > that runs later, after the properties have been rendered.
>
> right. My master.cfg looks like this:
>
> someSteps = [
>     myStep1(configInfo, someStepConfig),
>     myStep2(configInfo, someStepConfig)
> ]
>
> thisStepFactory.addSteps(someSteps)
>
> self.command is called in myStep1 etc.
>
>
> >    Most likely what is happening is that  Buildbot is then trying to
> send the
> > command, including the Interpolate instance, to the slave, and Twisted
> > is complaining that you're not allowed to send such objects over the
> > network.
>
> In this cases I would expect an error in twistd.log -- but nothing was
> showing up there. The error is just shown in the regarding stdio of the
> step in question.
>
> > In order to use renderables like Interpolate, you need to put them in
> > place before the step is started, which basically means in the step's
> > constructor.
> this would mean, that I would pass the information into the call of
> 'myStep1' for example? Has this behavior changed (actually 0.8.6 seems
> quite old by now)?
>
> I helped myself by using
>
> revision = self.getProperty('revision') in the start method of the
> subclassed shell command.
>
> Best
>      Jürgen
>
> --
>
> think project! International GmbH & Co. KG
> Jürgen Schulz-Brüssel
> Developer
>
> Phone +49 30 92 10 17-83
> Fax +49 30 92 10 17-50
> juergen.schulz-bruessel at thinkproject.com
>
> Legal information (imprint): www.thinkproject.com/en/info
>
> Rechtliche Informationen zum Absender (Impressum):
> www.thinkproject.com/de/info
>
>
>
> ------------------------------------------------------------------------------
> Slashdot TV.
> Video for Nerds.  Stuff that matters.
> http://tv.slashdot.org/
> _______________________________________________
> Buildbot-devel mailing list
> Buildbot-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/buildbot-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://buildbot.net/pipermail/devel/attachments/20140905/45158050/attachment.html>


More information about the devel mailing list