當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。