本文整理汇总了Python中crits.config.config.CRITsConfig.merge方法的典型用法代码示例。如果您正苦于以下问题:Python CRITsConfig.merge方法的具体用法?Python CRITsConfig.merge怎么用?Python CRITsConfig.merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类crits.config.config.CRITsConfig
的用法示例。
在下文中一共展示了CRITsConfig.merge方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: modify_configuration
# 需要导入模块: from crits.config.config import CRITsConfig [as 别名]
# 或者: from crits.config.config.CRITsConfig import merge [as 别名]
def modify_configuration(config_form, analyst):
"""
Modify the configuration with the submitted changes.
:param config_form: The form data.
:type config_form: dict
:param analyst: The user making the modifications.
:type analyst: str
:returns: dict with key "message"
"""
config = CRITsConfig.objects().first()
if not config:
config = CRITsConfig()
data = config_form.cleaned_data
allowed_hosts_list = data['allowed_hosts'].split(',')
allowed_hosts = ()
for allowed_host in allowed_hosts_list:
allowed_hosts = allowed_hosts + (allowed_host.strip(),)
data['allowed_hosts'] = allowed_hosts
service_dirs_list = data['service_dirs'].split(',')
service_dirs = ()
for service_dir in service_dirs_list:
service_dirs = service_dirs + (service_dir.strip(),)
data['service_dirs'] = service_dirs
config.merge(data, overwrite=True)
try:
config.save(username=analyst)
return {'message': "Success!"}
except Exception, e:
return {'message': "Failure: %s" % e}