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

Pierre Tardy tardyp at gmail.com
Sun Apr 30 07:55:11 UTC 2017


Hi Paulo,
The plugin modules are indeed not really modules, and you cannot really
call getattr on it or patch it.

I could not find documentation on the inner working of the plugin loader,
but there is always the source code.

the www service is loading dynamically the list of www plugins. You can get
soe ideas there:
https://github.com/buildbot/buildbot/blob/master/master/buildbot/www/service.py#L186
and
https://github.com/buildbot/buildbot/blob/master/master/buildbot/www/service.py#L270

Pierre

On Tue, Apr 25, 2017 at 1:30 PM Paulo Matos <pmatos at linki.tools> wrote:

> 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
> _______________________________________________
> users mailing list
> users at buildbot.net
> https://lists.buildbot.net/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.buildbot.net/pipermail/users/attachments/20170430/abab1b48/attachment.html>


More information about the users mailing list