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


Python TriggerType.get_by_name方法代码示例

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


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

示例1: _setup_sample_triggers

# 需要导入模块: from st2common.persistence.trigger import TriggerType [as 别名]
# 或者: from st2common.persistence.trigger.TriggerType import get_by_name [as 别名]
    def _setup_sample_triggers(
        self, names=["st2.test.trigger1", "st2.test.trigger2", "st2.test.trigger3", "st2.test.trigger4"]
    ):
        trigger_dbs = []
        for name in names:
            trigtype = None
            try:
                trigtype = TriggerTypeDB()
                trigtype.pack = "dummy_pack_1"
                trigtype.name = name
                trigtype.description = ""
                trigtype.payload_schema = {}
                trigtype.parameters_schema = {}
                try:
                    trigtype = TriggerType.get_by_name(name)
                except:
                    trigtype = TriggerType.add_or_update(trigtype)
            except NotUniqueError:
                pass

            created = TriggerDB()
            created.name = name
            created.pack = "dummy_pack_1"
            created.description = ""
            created.type = trigtype.get_reference().ref

            if name in ["st2.test.trigger4"]:
                created.parameters = {"url": "sample"}
            else:
                created.parameters = {}

            created = Trigger.add_or_update(created)
            trigger_dbs.append(created)

        return trigger_dbs
开发者ID:ipv1337,项目名称:st2,代码行数:37,代码来源:test_rule_engine.py

示例2: _setup_sample_triggers

# 需要导入模块: from st2common.persistence.trigger import TriggerType [as 别名]
# 或者: from st2common.persistence.trigger.TriggerType import get_by_name [as 别名]
    def _setup_sample_triggers(self, names=['st2.test.trigger1', 'st2.test.trigger2',
                                            'st2.test.trigger3', 'st2.test.trigger4']):
        trigger_dbs = []
        for name in names:
            trigtype = None
            try:
                trigtype = TriggerTypeDB(pack='dummy_pack_1', name=name, description='',
                                         payload_schema={}, parameters_schema={})
                try:
                    trigtype = TriggerType.get_by_name(name)
                except:
                    trigtype = TriggerType.add_or_update(trigtype)
            except NotUniqueError:
                pass

            created = TriggerDB(pack='dummy_pack_1', name=name, description='',
                                type=trigtype.get_reference().ref)

            if name in ['st2.test.trigger4']:
                created.parameters = {'url': 'sample'}
            else:
                created.parameters = {}

            created = Trigger.add_or_update(created)
            trigger_dbs.append(created)

        return trigger_dbs
开发者ID:AlexeyDeyneko,项目名称:st2,代码行数:29,代码来源:test_rule_engine.py


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