[users at bb.net] Dynamic generation of schedulers in bb9

Paulo Matos pmatos at linki.tools
Tue Apr 25 11:30:37 UTC 2017

Hi all,

Using bb0.9.6 here with Python3.
All good, except when I try to do dynamic loading of schedulers. I think
this might be an issue with Python instead of bb but my guess is that
someone here might be able to help.

If I do:

from buildbot.plugins import *
b = schedulers.SingleBranchScheduler(...)

all is good _but_ imagine I have a string with 'SingleBranchScheduler'
and want to create a SingleBranchScheduler.

I tried:
from buildbot.plugins import *
import importlib

m = importlib.import_module('schedulers')
schedclass = getattr(m, 'SingleBranchScheduler')
b = schedclass(...)

This fails at the import_module time. My guess is that this is due to
the tricks being playing by plugins/__init__.py to allow importing
schedulers. However, I am not sure how to work around this.

My goal is to be able to have a json interface to define schedulers in
an easy way and read that in master.cfg. Then, of course, scheduler
class names will come in as a string and I need to transform that into a
class for instantiation.

Kind regards,

Paulo Matos

More information about the users mailing list