[Buildbot-devel] Custom functions in master.cfg

Christoph Spielmann christoph.spielmann at machineering.de
Mon Jul 23 09:24:12 UTC 2012


Hi,

On 23.07.2012 10:58, Dmitry Nezhevenko wrote:
> On Mon, Jul 23, 2012 at 09:09:04AM +0200, Christoph Spielmann wrote:
>> Hi,
>>
>> In my configuration i defined the following function to create a string
>> in the form "0_Sunday",..., "6_Saturday":
>>
>> from datetime import date
>> import locale
>>
>> def createUploadTargetDirectory():
>>        locale.setlocale(locale.LC_ALL,'de_DE')
>>        d=date.today()
>>        return "{0}_{1}".format(((d.weekday()+1)%7),d.strftime("%A"))
>>
>> I use this function in one of my buildsteps like this:
>>
>> factory.addStep(DirectoryUpload(slavesrc="..\\dist\\setup",masterdest="/bla/{0}".format(createUploadTargetDirectory())))
>>
>> if i type the function into the python-commandline it works as expected
>> but buildbot somehow seems to always get the date from the master when
>> it was restarted the last time (i assume thats when the master.cfg is
>> actually loaded...)
> Since master.cfg is just a python script, createUploadTargetDirectory() is
> evaluated only once :)

Yeah that's what i assumed... You learn new stuff every day! ;)

>
> You need to use "WithProperties" helper
> 	http://buildbot.net/buildbot/docs/latest/manual/cfg-properties.html#withproperties
>
> In your case it'll be something like this
> 	slavesrc=WithProperties("/bla/%(dir)s", dir=createUploadTargetDirectory)
>
> You should pass callable to it, so there should be no "()" when passing
> createUploadTargetDirectory. Also IIRC you'll need to change signature of
> your createUploadTargetDirectory() function. It should accept one
> parameter -- map of exisitng build properties.

Ah i haven't thought of this possibility! Thanks for the extensive hint!

Christoph

>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>
>
> _______________________________________________
> Buildbot-devel mailing list
> Buildbot-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/buildbot-devel


-- 
--------------------------------------------
Dipl.-Ing. Christoph Spielmann

machineering GmbH & Co. KG
Simulation und Automatisierung
Pfrontener Platz 25a
80686 München

Tel: + 49 (0) 89 54 72 69 - 28
Mail:  christoph.spielmann at machineering.de
Web: www.machineering.de

--------------------------------------------

machineering GmbH & Co. KG, HRA 94550, Amtsgericht München
machineering Verwaltungs-GmbH, HRB 181877, Amtsgericht München
Ust-IdNr.: DE268988178
Geschäftsführung: B.Freyer

--------------------------------------------

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://buildbot.net/pipermail/devel/attachments/20120723/64b5d1ba/attachment.html>


More information about the devel mailing list