本文整理汇总了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