[Buildbot-devel] subclasses clarification

Brian Warner warner-buildbot at lothar.com
Sun Sep 24 02:21:27 UTC 2006


"Leibowitz, Michael" <michael.leibowitz at intel.com> writes:

> If I need to make a subclass for a specialization, where is the
> appropriate place to define my subclass?  It would be ideal if I could
> put it someplace that was not in the buildbot source, such as
> master.cfg.  Is this possible/preferred?  Thanks.

You can do it in master.cfg, but you can also write these subclasses in a
separate file and then import them. I've done the following several times:

master.cfg:
  from config_helper import MySubclass
  c['builders'] = ...
  ...

config_helper.py:
  from buildbot.steps.shell import ShellCommand
  class MySubclass(ShellCommand):
      command = ['stuff', 'here']
      ...

If you do this, keep in mind that reloading the buildmaster's config file
(with 'buildbot sighup DIR', or the debugclient's Reload Config button) will
not re-read the config_helper.py module. This is because python caches the
contents of that module. You can add this to your master.cfg:

 import config_helper
 reload(config_helper)
 MySubclass = config_helper.MySubclass

but then any Builders which use MySubclass will *always* be restarted, even
if config_helper.py doesn't change, since at that point the class object is
always changing.


cheers,
 -Brian




More information about the devel mailing list