[Buildbot-devel] More Python Trouble

David A. Greene greened at obbligato.org
Wed Dec 3 17:15:30 UTC 2008


On Monday 01 December 2008 12:41, Dustin J. Mitchell wrote:
> On Mon, Dec 1, 2008 at 1:14 PM, David A. Greene <greened at obbligato.org> 
wrote:
> >  def __init__(self, type, *args, **kwargs):
> >    description = "testing " + type
> >    descriptionDone = "test " + type
> >    Test.__init__(self, *args, **kwargs)
>
> BuildStep objects are their own factories, and you have to jump
> through a lot of hoops to make that work.  Take a look at, for
> example, the ShellCommand constructor.  All arguments must be keyword
> arguments, and you must call self.addFactoryArguments with any
> important arguments.

Ok, I looked at ShellCommand and tried to pattern things after that and 
WarningCountingShellCommand:

class DejaGNUTester(Test):
  def __init__(self, type, **kwargs):
        # most of our arguments get passed through to the Test
        # that we create, but first strip out the ones that we pass to
        # BuildStep (like haltOnFailure and friends), and a couple that we
        # consume ourselves.

        if type:
            self.description = "testing " + type
            self.descriptionDone = "test " + type
        if isinstance(self.description, str):
            self.description = [self.description]
        if isinstance(self.descriptionDone, str):
            self.descriptionDone = [self.descriptionDone]

        self.total = 0
        self.command=["make", "check"]

        # pull out the ones that Test wants, then upcall
        buildstep_kwargs = {}
        for k in kwargs.keys()[:]:
            if k in self.__class__.parms:
                buildstep_kwargs[k] = kwargs[k]
                del kwargs[k]
        Test.__init__(self, **buildstep_kwargs)
        self.addFactoryArguments(description="testing " + type,
                                 descriptionDone="test " + type)

I'm still getting the same error:

2008-12-03 05:07:02-0600 [Broker,1,172.30.12.179] error while creating step, 
factory=__builtin__.DejaGNUTester, args={'descriptionDone': 'test 
initial-llvm', 'workdir': None, 'command': None, 'description': 'testing 
initial-llvm', 'logfiles': {}}
2008-12-03 05:07:02-0600 [Broker,1,172.30.12.179] Build.setupBuild failed
2008-12-03 05:07:02-0600 [Broker,1,172.30.12.179] Unhandled Error
        Traceback (most recent call last):
          File "lib/python/twisted/internet/defer.py", line 243, in callback
            self._startRunCallbacks(result)
          File "lib/python/twisted/internet/defer.py", line 312, in 
_startRunCallbacks
            self._runCallbacks()
          File "lib/python/twisted/internet/defer.py", line 328, in 
_runCallbacks
            self.result = callback(self.result, *args, **kw)
          File "lib/python/buildbot/process/builder.py", line 637, in 
_startBuild_2
            d = build.startBuild(bs, self.expectations, sb)
        --- <exception caught here> ---
          File "lib/python/buildbot/process/base.py", line 336, in startBuild
            self.setupBuild(expectations) # create .steps
          File "lib/python/buildbot/process/base.py", line 387, in setupBuild
            step = factory(**args)
        exceptions.TypeError: __init__() takes exactly 2 non-keyword arguments 
(1 given)

Is there a good reference I can go look at to learn about Python factories and 
how they're supposed to work.  The official Python documentation leaves a lot 
to be desired.

Thanks!

                                                 -Dave




More information about the devel mailing list