返回介绍

2.5.19. DbConfig

发布于 2023-09-20 23:50:39 字数 2456 浏览 0 评论 0 收藏 0

Caution

Buildbot no longer supports Python 2.7 on the Buildbot master.

2.5.19. DbConfig

DbConfig is a utility for master.cfg to get easy-to-use key-value storage in the Buildbot database.

DbConfig can get and store any json-able object to the db for use by other masters or separate UI plugins to edit them.

The design is intentionally simplistic, as the focus is on ease of use rather than efficiency. A separate db connection is created each time get() or set() is called.

Example:

from buildbot.plugins import util, worker

c = BuildmasterConfig = {}
c['db_url'] = 'mysql://username:password@mysqlserver/buildbot'
dbConfig = util.DbConfig(BuildmasterConfig, basedir)
workers = dbConfig.get("workers")
c['workers'] = [
    worker.Worker(worker['name'], worker['passwd'],
                  properties=worker.get('properties')),
    for worker in workers
]
class DbConfig
__init__(BuildmasterConfig, basedir)
Parameters:
  • BuildmasterConfig – the BuildmasterConfig, where db_url is already configured

  • basedirbasedir global variable of the master.cfg run environment. SQLite urls are relative to this dir

get(name, default=MarkerClass)
Parameters:
  • name – the name of the config variable to retrieve

  • default – in case the config variable has not been set yet, default is returned if defined, else KeyError is raised

set(name, value)
Parameters:
  • name – the name of the config variable to be set

  • value – the value of the config variable to be set

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文