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


Python CRITsConfig.save方法代码示例

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


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

示例1: modify_configuration

# 需要导入模块: from crits.config.config import CRITsConfig [as 别名]
# 或者: from crits.config.config.CRITsConfig import save [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}
开发者ID:dmbuchta,项目名称:crits,代码行数:33,代码来源:handlers.py

示例2: force_reset_config

# 需要导入模块: from crits.config.config import CRITsConfig [as 别名]
# 或者: from crits.config.config.CRITsConfig import save [as 别名]
def force_reset_config():
    """
    Resets the values for the CRITsConfig class by dropping the
    database collection and then saving a new default CRITsConfig.
    """

    print "Resetting CRITs configuration settings."
    CRITsConfig.drop_collection();

    crits_config = CRITsConfig();
    crits_config.save();
开发者ID:dicato,项目名称:crits,代码行数:13,代码来源:setconfig.py

示例3: get_config

# 需要导入模块: from crits.config.config import CRITsConfig [as 别名]
# 或者: from crits.config.config.CRITsConfig import save [as 别名]
def get_config():
    """
    Get the CRITs configuration.

    :returns: :class:`crits.config.config.CRITsConfig`
    """

    crits_config = CRITsConfig.objects().first()
    if not crits_config:
        crits_config = CRITsConfig()
        crits_config.save()
    return crits_config
开发者ID:AInquel,项目名称:crits,代码行数:14,代码来源:tests.py

示例4: create_config_if_not_exist

# 需要导入模块: from crits.config.config import CRITsConfig [as 别名]
# 或者: from crits.config.config.CRITsConfig import save [as 别名]
def create_config_if_not_exist():
    """
    If the CRITsConfig already exists then the CRITsConfig is returned,
    otherwise a new CRITsConfig will be created, saved, and returned.

    Returns:
        Returns the CRITsConfig if it already exists, otherwise a
        default CRITsConfig is returned.
    """

    crits_config = CRITsConfig.objects().first()
    if not crits_config:
        print "Creating a new CRITs configuration."
        crits_config = CRITsConfig()
        crits_config.save()
    else:
        print "A CRITs configuration already exists. Skipping default creation."

    return crits_config
开发者ID:dicato,项目名称:crits,代码行数:21,代码来源:setconfig.py

示例5: prep_db

# 需要导入模块: from crits.config.config import CRITsConfig [as 别名]
# 或者: from crits.config.config.CRITsConfig import save [as 别名]
def prep_db():
    """
    Prep the DB for testing.
    """

    clean_db()
    # Create a new default config
    crits_config = CRITsConfig()
    crits_config.save()
    # Add Source
    handlers.add_new_source(TSRC, TRANDUSER)

    # Add User
    user = CRITsUser.create_user(username=TUSER_NAME,
                                 password=TUSER_PASS,
                                 email=TUSER_EMAIL
                                 )
    user.first_name = TUSER_FNAME
    user.last_name = TUSER_LNAME
    user.save()

    # Add test source object
    '''
开发者ID:armtash,项目名称:crits,代码行数:25,代码来源:tests.py

示例6: prep_db

# 需要导入模块: from crits.config.config import CRITsConfig [as 别名]
# 或者: from crits.config.config.CRITsConfig import save [as 别名]
def prep_db():
    """
    Prep the DB for testing.
    """

    clean_db()
    # Create a new default config
    crits_config = CRITsConfig()
    crits_config.save()
    # Add Source
    handlers.add_new_source(TSRC, TRANDUSER)
    # Add User
    user = CRITsUser.create_user(username=TUSER_NAME,
                                 password=TUSER_PASS,
                                 email=TUSER_EMAIL,
                                 )
    user.first_name = TUSER_FNAME
    user.last_name = TUSER_LNAME
    user.save()
    # Add test source object
    obj = TestSourceObject()
    obj.name = TOBJS_NAME
    obj.value = TOBJS_VALUE
    obj.add_source(source=TSRC, analyst=TUSER_NAME)
    obj.save()
    # Add another with Different source
    obj = TestSourceObject()
    obj.name = TOBJS_NAME
    obj.value = TOBJS_VALUE
    obj.add_source(source=TUNKSRC, analyst=TRANDUSER)
    obj.save()
    # Add test non-source object
    obj = TestObject()
    obj.name = TOBJ_NAME
    obj.value = TOBJ_VALUE
    obj.save()
开发者ID:AInquel,项目名称:crits,代码行数:38,代码来源:tests.py


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