[Buildbot-devel] problem in overriding FileUpload.__init__()
Dustin J. Mitchell
dustin at v.igoro.us
Sun May 25 19:42:51 UTC 2014
The problem has to do with the use of steps as step factories -- that
single step object in your master.cfg needs to be able to create a new
step instance for each build, and thus stores its constructor
arguments, even the defaults. Check out how FileUpload handles its
args - there was a function named something like addFactoryArgs that
you'll need to call for any custom args you add.
This has all been fixed in more recent versions of Buildbot.
On Sun, May 25, 2014 at 3:04 PM, Giovanni Gherdovich
<g.gherdovich at gmail.com> wrote:
> Hi all,
>
> I am having problems in subclassing buildbot.steps.transfer.FileUpload
> and overriding its __init__() method.
>
> My system has Buildbot 0.8.1 and Twisted 10.1.0;
> I know it's quite outdated, but the cluster is run by people
> who don't like to change things and I don't have a say on it.
>
> The thing is that if I subclass FileUpload with
>
> ---------------------------------------------------
> class FileUpload2(FileUpload):
> def __init__(self, slavesrc, masterdest):
> FileUpload.__init__(self,
> slavesrc=slavesrc,
> masterdest=masterdest)
> ---------------------------------------------------
>
> i.e., I do nothing but limiting the arguments of the constructor to two,
> and instantiate it with
>
> ---------------------------------------------------
> f = factory.BuildFactory()
> f.addStep(FileUpload2(slavesrc="/etc/passwd",
> masterdest="~/foo"))
> ---------------------------------------------------
>
> I get the following error in the twisted.log of the master:
>
> ---------------------------------------------------
> 2014-05-25 20:31:38+0200 [Broker,1,127.0.0.1] <Build
> buildbot-full>.startBuild
> 2014-05-25 20:31:38+0200 [Broker,1,127.0.0.1] error while creating step,
> factory=__builtin__.FileUpload2,
> args={'masterdest': '~/foo',
> 'maxsize': None, 'workdir': None, 'mode': None, 'blocksize': 16384,
> 'slavesrc': '/etc/passwd'}
> 2014-05-25 20:31:38+0200 [Broker,1,127.0.0.1] Build.setupBuild failed
> 2014-05-25 20:31:38+0200 [Broker,1,127.0.0.1] Unhandled Error
> Traceback (most recent call last):
> File
> "/home/buildbot/sandbox/local/lib/python2.7/site-packages/Twisted-10.1.0-py2.7-linux-x86_64.egg/twisted/internet/defer.py",
> line 318, in callback
> self._startRunCallbacks(result)
> File
> "/home/buildbot/sandbox/local/lib/python2.7/site-packages/Twisted-10.1.0-py2.7-linux-x86_64.egg/twisted/internet/defer.py",
> line 424, in _startRunCallbacks
> self._runCallbacks()
> File
> "/home/buildbot/sandbox/local/lib/python2.7/site-packages/Twisted-10.1.0-py2.7-linux-x86_64.egg/twisted/internet/defer.py",
> line 441, in _runCallbacks
> self.result = callback(self.result, *args, **kw)
> File
> "/home/buildbot/sandbox/local/lib/python2.7/site-packages/buildbot-0.8.1-py2.7.egg/buildbot/process/builder.py",
> line 840, in _startBuild_2
> d = build.startBuild(bs, self.expectations, sb)
> --- <exception caught here> ---
> File
> "/home/buildbot/sandbox/local/lib/python2.7/site-packages/buildbot-0.8.1-py2.7.egg/buildbot/process/base.py",
> line 214, in startBuild
> self.setupBuild(expectations) # create .steps
> File
> "/home/buildbot/sandbox/local/lib/python2.7/site-packages/buildbot-0.8.1-py2.7.egg/buildbot/process/base.py",
> line 265, in setupBuild
> step = factory(**args)
> exceptions.TypeError: __init__() got an unexpected keyword argument
> 'maxsize'
> ---------------------------------------------------
>
> Here my complete minimal master.cfg:
> there is only one BuildStep, which moves /etc/passwd from the slave
> to a ~/foo file on the master.
>
> ---------------------------------------------------
> # -*- python -*-
> from buildbot.buildslave import BuildSlave
> from buildbot.scheduler import Scheduler
> from buildbot.process import factory
> from buildbot.status import html
> from buildbot.status.web import auth, authz
> from buildbot.steps.transfer import FileUpload
> from buildbot.changes.pb import PBChangeSource
>
> c = BuildmasterConfig = {}
> c['db_url'] = "sqlite:///state.sqlite"
> c['slaves'] = [BuildSlave("example-slave", "pass")]
> c['slavePortnum'] = 9989
>
> c['change_source'] = PBChangeSource()
>
> c['schedulers'] = []
> c['schedulers'].append(Scheduler(name="all", branch=None,
> treeStableTimer=None,
> builderNames=["buildbot-full"]))
>
> class FileUpload2(FileUpload):
> def __init__(self, slavesrc, masterdest):
> FileUpload.__init__(self,
> slavesrc=slavesrc,
> masterdest=masterdest)
>
>
> f = factory.BuildFactory()
> f.addStep(FileUpload2(slavesrc="/etc/passwd",
> masterdest="~/foo"))
>
> b = {'name': "buildbot-full",
> 'slavename': "example-slave",
> 'builddir': "full",
> 'factory': f,
> }
> c['builders'] = [b]
> c['status'] = []
>
> authz_cfg=authz.Authz(
> gracefulShutdown = False,
> forceBuild = False,
> forceAllBuilds = False,
> pingBuilder = False,
> stopBuild = False,
> stopAllBuilds = False,
> cancelPendingBuild = False,
> )
> c['status'].append(html.WebStatus(http_port=8010, authz=authz_cfg))
> c['buildbotURL'] = "http://localhost:8010/"
> ---------------------------------------------------
>
> Regards,
> GGhh
>
> ------------------------------------------------------------------------------
> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
> Instantly run your Selenium tests across 300+ browser/OS combos.
> Get unparalleled scalability from the best Selenium testing platform
> available
> Simple to use. Nothing to install. Get started now for free."
> http://p.sf.net/sfu/SauceLabs
> _______________________________________________
> 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