当前位置: 首页>>代码示例>>Python>>正文


Python Config.config_file方法代码示例

本文整理汇总了Python中barman.config.Config.config_file方法的典型用法代码示例。如果您正苦于以下问题:Python Config.config_file方法的具体用法?Python Config.config_file怎么用?Python Config.config_file使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在barman.config.Config的用法示例。


在下文中一共展示了Config.config_file方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: build_config_from_dicts

# 需要导入模块: from barman.config import Config [as 别名]
# 或者: from barman.config.Config import config_file [as 别名]
def build_config_from_dicts(global_conf=None, main_conf=None,
                            test_conf=None,
                            config_name=None):
    """
    Utility method, generate a barman.config.Config object

    It has  a minimal configuration and a single server called "main".
    All options can be override using the optional arguments

    :param dict[str,str|None]|None global_conf: using this dictionary
        it is possible to override or add new values to the [barman] section
    :param dict[str,str|None]|None main_conf: using this dictionary
        it is possible to override/add new values to the [main] section
    :return barman.config.Config: a barman configuration object
    """
    # base barman section
    base_barman = {
        'barman_home': '/some/barman/home',
        'barman_user': '{USER}',
        'log_file': '%(barman_home)s/log/barman.log',
        'archiver': True
    }
    # base main section
    base_main = {
        'description': '" Text with quotes "',
        'ssh_command': 'ssh -c "arcfour" -p 22 [email protected]',
        'conninfo': 'host=pg01.nowhere user=postgres port=5432'
    }
    # base test section
    base_test = {
        'description': '" Text with quotes "',
        'ssh_command': 'ssh -c "arcfour" -p 22 [email protected]',
        'conninfo': 'host=pg02.nowhere user=postgres port=5433'
    }
    # update map values of the two sections
    if global_conf is not None:
        base_barman.update(global_conf)
    if main_conf is not None:
        base_main.update(main_conf)
    if test_conf is not None:
        base_test.update(test_conf)

    # writing the StringIO obj with the barman and main sections
    config_file = StringIO()
    config_file.write('\n[barman]\n')
    for key in base_barman.keys():
        config_file.write('%s = %s\n' % (key, base_barman[key]))

    config_file.write('[main]\n')
    for key in base_main.keys():
        config_file.write('%s = %s\n' % (key, base_main[key]))

    config_file.write('[test]\n')
    for key in base_test.keys():
        config_file.write('%s = %s\n' % (key, base_main[key]))

    config_file.seek(0)
    config = Config(config_file)
    config.config_file = config_name or 'build_config_from_dicts'
    return config
开发者ID:2ndquadrant-it,项目名称:barman,代码行数:62,代码来源:testing_helpers.py


注:本文中的barman.config.Config.config_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。