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


Python Status.get方法代码示例

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


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

示例1: stop

# 需要导入模块: from status import Status [as 别名]
# 或者: from status.Status import get [as 别名]
 def stop(self):
   self.active = False
   game_slugs = get_game_slugs()
   
   if self.slug in game_slugs:
     game_slugs.remove(self.slug)
     memcache.set('game_slugs', game_slugs)
   
   
   serialized_status = memcache.get_multi(self.status_ids,
                                          key_prefix='status')
   
   # Just copying my status_ids list to make some changes localy
   missing_status_ids = list(self.status_ids)
   for status_id, status in serialized_status.iteritems():
     deserialized_status = deserialize(status)
     deserialized_status.player.leave_game(self)
     missing_status_ids.remove(status_id)
   
   # Taking the missing status in database
   if missing_status_ids:
     missing_status = Status.get(missing_status_ids)
     for status in missing_status:
       status.player.leave_game(self)
   
   memcache.delete('game'+self.slug)
   self.status_ids = []
   self.put()
开发者ID:virtualjoker,项目名称:jankenpony,代码行数:30,代码来源:game.py

示例2: BondStatusApi

# 需要导入模块: from status import Status [as 别名]
# 或者: from status.Status import get [as 别名]
class BondStatusApi(remote.Service):
    def __init__(self):
        sam_base_url = config.get('sam', 'BASE_URL')

        providers = {provider_name: FenceApi(config.get(provider_name, 'FENCE_BASE_URL'))
                     for provider_name in config.sections() if provider_name != 'sam'}

        sam_api = SamApi(sam_base_url)
        self.status_service = Status(sam_api, providers)

    @endpoints.method(
        message_types.VoidMessage,
        StatusResponse,
        path='/status',
        http_method='GET',
        name='status')
    def status(self, request):
        subsystems = self.status_service.get()
        ok = all(subsystem["ok"] for subsystem in subsystems)
        response = StatusResponse(ok=ok,
                                  subsystems=[SubSystemStatusResponse(ok=subsystem["ok"],
                                                                      message=subsystem["message"],
                                                                      subsystem=subsystem["subsystem"])
                                              for subsystem in subsystems])
        if ok:
            return response
        else:
            raise endpoints.InternalServerErrorException(response)
开发者ID:DataBiosphere,项目名称:bond,代码行数:30,代码来源:main.py

示例3: get_status_dict

# 需要导入模块: from status import Status [as 别名]
# 或者: from status.Status import get [as 别名]
 def get_status_dict(self):
   # It will returns a serialized status in mem_cache
   serialized_status = memcache.get_multi(self.status_ids,
                                               key_prefix='status')
   # Just copying my status_ids list to make some changes localy
   missing_status_ids = list(self.status_ids)
   game_status = {}
   for status_id, status in serialized_status.iteritems():
     game_status[status_id] = deserialize(status)
     missing_status_ids.remove(status_id)
   
   # Taking the missing status in database and add them in memcache
   if missing_status_ids:
     missing_status = Status.get(missing_status_ids)
     serialized_status = {}
     for status in missing_status:
       game_status[status_id] = deserialize(status)
       serialized_status[status.id] = serialize(status)
       
     memcache.set_multi(serialized_status, key_prefix='status')
   
   # I really dunno why, but the game_status list in this function
   # works like a list of string, and when this function pass to some
   # function or when it returns, game_status assume its really identity
   # that is a list of status, not a list of strings... (crazy, I know)
   self.actualise_status(game_status)
   
   return game_status # Returns a random list of Status playing this game
开发者ID:virtualjoker,项目名称:jankenpony,代码行数:30,代码来源:game.py

示例4: test_sam_error

# 需要导入模块: from status import Status [as 别名]
# 或者: from status.Status import get [as 别名]
 def test_sam_error(self):
     status = Status(self._mock_sam_api(False), {"fence": self._mock_fence_api(True)})
     self.assertItemsEqual(status.get(), [
         {"ok": True, "message": "", "subsystem": Subsystems.memcache},
         {"ok": True, "message": "", "subsystem": Subsystems.datastore},
         {"ok": True, "message": "", "subsystem": "fence"},
         {"ok": False, "message": "sam down", "subsystem": Subsystems.sam},
     ])
开发者ID:DataBiosphere,项目名称:bond,代码行数:10,代码来源:status_test.py

示例5: test_datastore_error

# 需要导入模块: from status import Status [as 别名]
# 或者: from status.Status import get [as 别名]
 def test_datastore_error(self):
     status = Status(self._mock_sam_api(True), {"fence": self._mock_fence_api(True)})
     status._datastore_status = MagicMock(return_value=(False, "datastore down"))
     self.assertItemsEqual(status.get(), [
         {"ok": True, "message": "", "subsystem": Subsystems.memcache},
         {"ok": False, "message": "datastore down", "subsystem": Subsystems.datastore},
         {"ok": True, "message": "", "subsystem": "fence"},
         {"ok": True, "message": "", "subsystem": Subsystems.sam},
     ])
开发者ID:DataBiosphere,项目名称:bond,代码行数:11,代码来源:status_test.py

示例6: get_status

# 需要导入模块: from status import Status [as 别名]
# 或者: from status.Status import get [as 别名]
 def get_status(self):
   # Returns a dict of serialized status saved in cache
   serialized_status = memcache.get_multi(self.status_ids,
                                          key_prefix='status')
   
   # Just copying my status_ids list to make some changes localy
   missing_status_ids = list(self.status_ids)
   player_status = []
   for status_id, status in serialized_status.iteritems():
     player_status.append(deserialize(status))
     missing_status_ids.remove(status_id)
   
   # Taking the missing status in database and add them in memcache
   if missing_status_ids:
     missing_status = Status.get(missing_status_ids)
     serialized_status = {}
     for status in missing_status:
       if status:
         serialized_status[status.id] = serialize(status)
         player_status.append(status)
     memcache.set_multi(serialized_status, key_prefix='status')
   
   return player_status
开发者ID:virtualjoker,项目名称:jankenpony,代码行数:25,代码来源:player.py

示例7: test_memcache_error

# 需要导入模块: from status import Status [as 别名]
# 或者: from status.Status import get [as 别名]
 def test_memcache_error(self):
     status = Status(self._mock_sam_api(True), {"fence": self._mock_fence_api(True)})
     message = "memcache down"
     status._get_cached_status = MagicMock(side_effect=Exception(message))
     self.assertEqual(status.get(), [{"ok": False, "message": message, "subsystem": Subsystems.memcache}])
开发者ID:DataBiosphere,项目名称:bond,代码行数:7,代码来源:status_test.py

示例8: test_ok_status

# 需要导入模块: from status import Status [as 别名]
# 或者: from status.Status import get [as 别名]
 def test_ok_status(self):
     status = Status(self._mock_sam_api(True), {"fence": self._mock_fence_api(True)})
     self.assertEqual(len(status.get()), 4)
     self.assertTrue(all(subsystem["ok"] for subsystem in status.get()))
开发者ID:DataBiosphere,项目名称:bond,代码行数:6,代码来源:status_test.py


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