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


Python KeyValuePair.get_by_name方法代码示例

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


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

示例1: get_kvp_for_name

# 需要导入模块: from st2common.persistence.keyvalue import KeyValuePair [as 别名]
# 或者: from st2common.persistence.keyvalue.KeyValuePair import get_by_name [as 别名]
def get_kvp_for_name(name):
    try:
        kvp_db = KeyValuePair.get_by_name(name)
    except ValueError:
        kvp_db = None

    return kvp_db
开发者ID:mahak,项目名称:st2,代码行数:9,代码来源:keyvalues.py

示例2: get_required_sensor_refs

# 需要导入模块: from st2common.persistence.keyvalue import KeyValuePair [as 别名]
# 或者: from st2common.persistence.keyvalue.KeyValuePair import get_by_name [as 别名]
    def get_required_sensor_refs(self):
        partition_lookup_key = self._get_partition_lookup_key(self.sensor_node_name)

        kvp = KeyValuePair.get_by_name(partition_lookup_key)
        sensor_refs_str = kvp.value if kvp.value else ''
        self._supported_sensor_refs = set([
            sensor_ref.strip() for sensor_ref in sensor_refs_str.split(',')])
        return self._supported_sensor_refs
开发者ID:lyandut,项目名称:st2,代码行数:10,代码来源:partitioners.py

示例3: test_kvp_crud

# 需要导入模块: from st2common.persistence.keyvalue import KeyValuePair [as 别名]
# 或者: from st2common.persistence.keyvalue.KeyValuePair import get_by_name [as 别名]
    def test_kvp_crud(self):
        saved = KeyValuePairModelTest._create_save_kvp()
        retrieved = KeyValuePair.get_by_name(saved.name)
        self.assertEqual(saved.id, retrieved.id, "Same KeyValuePair was not returned.")

        # test update
        self.assertEqual(retrieved.value, "0123456789ABCDEF")
        retrieved.value = "ABCDEF0123456789"
        saved = KeyValuePair.add_or_update(retrieved)
        retrieved = KeyValuePair.get_by_name(saved.name)
        self.assertEqual(retrieved.value, "ABCDEF0123456789", "Update of key value failed")

        # cleanup
        KeyValuePairModelTest._delete([retrieved])
        try:
            retrieved = KeyValuePair.get_by_name(saved.name)
        except StackStormDBObjectNotFoundError:
            retrieved = None
        self.assertIsNone(retrieved, "managed to retrieve after failure.")
开发者ID:rlugojr,项目名称:st2,代码行数:21,代码来源:test_db.py

示例4: _get_kv

# 需要导入模块: from st2common.persistence.keyvalue import KeyValuePair [as 别名]
# 或者: from st2common.persistence.keyvalue.KeyValuePair import get_by_name [as 别名]
 def _get_kv(self, key):
     kvp = None
     try:
         kvp = KeyValuePair.get_by_name(key)
     except ValueError:
         # ValueErrors are expected in case of partial lookups
         pass
     # A good default value for un-matched value is empty string since that will be used
     # for rendering templates.
     return kvp.value if kvp else ''
开发者ID:AlexeyDeyneko,项目名称:st2,代码行数:12,代码来源:keyvalues.py

示例5: test_kvp_crud

# 需要导入模块: from st2common.persistence.keyvalue import KeyValuePair [as 别名]
# 或者: from st2common.persistence.keyvalue.KeyValuePair import get_by_name [as 别名]
    def test_kvp_crud(self):
        saved = KeyValuePairModelTest._create_save_kvp()
        retrieved = KeyValuePair.get_by_name(saved.name)
        self.assertEqual(saved.id, retrieved.id,
                         'Same KeyValuePair was not returned.')

        # test update
        self.assertEqual(retrieved.value, '0123456789ABCDEF')
        retrieved.value = 'ABCDEF0123456789'
        saved = KeyValuePair.add_or_update(retrieved)
        retrieved = KeyValuePair.get_by_name(saved.name)
        self.assertEqual(retrieved.value, 'ABCDEF0123456789',
                         'Update of key value failed')

        # cleanup
        KeyValuePairModelTest._delete([retrieved])
        try:
            retrieved = KeyValuePair.get_by_name(saved.name)
        except ValueError:
            retrieved = None
        self.assertIsNone(retrieved, 'managed to retrieve after failure.')
开发者ID:azamsheriff,项目名称:st2,代码行数:23,代码来源:test_db.py

示例6: __get_by_name

# 需要导入模块: from st2common.persistence.keyvalue import KeyValuePair [as 别名]
# 或者: from st2common.persistence.keyvalue.KeyValuePair import get_by_name [as 别名]
 def __get_by_name(name):
     try:
         return KeyValuePair.get_by_name(name)
     except ValueError as e:
         LOG.debug('Database lookup for name="%s" resulted in exception : %s.', name, e)
         return None
开发者ID:AlexeyDeyneko,项目名称:st2,代码行数:8,代码来源:keyvalue.py


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