本文整理汇总了Python中Game.Game.get方法的典型用法代码示例。如果您正苦于以下问题:Python Game.get方法的具体用法?Python Game.get怎么用?Python Game.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game.Game
的用法示例。
在下文中一共展示了Game.get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_game_view
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import get [as 别名]
def get_game_view():
"""Loads the GameView object for each response."""
if has_request_context() and current_user.is_authenticated():
if request.args.get('game'):
session['current_game'] = request.args.get('game')
if session.get('current_game', False):
return current_user.view(Game.get(session['current_game']))
return None
示例2: Parser
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import get [as 别名]
class Parser(threading.Thread):
def __init__(self, address):
super(Parser, self).__init__()
self.address = address
self.queue = Queue.Queue()
self.go = True
self.time = 0.0
self.startup = timeit.default_timer()
self.last_message = time.time()
self.server = GameServer()
self.game = Game()
self.engine = Engine()
self.player = Player()
self.game_player = GamePlayer()
self.game_map = GameMap()
self.game_weapon = GameWeapon()
self.cur_server = self.server.get(address=self.address)
self.cur_game = self.game.get(id=self.cur_server['game_id'])
def run(self):
start = timeit.default_timer()
self.sync()
# Process the messages
while self.go:
self.last_message = time.time()
# Use a non-blocking fetch so we can always quit the loop
buf = ""
try:
try:
message = self.queue.get(False)
except (KeyboardInterrupt):
return
except (Queue.Empty):
try:
time.sleep(0.1)
continue
except:
pass
except:
pass
# Start a timer
start = timeit.default_timer()
buf += self.parse(message)
# Finished, create the end timer
self.time += (timeit.default_timer()-start)
#done
self.queue.task_done()
# Print
if buf:
print(buf)
def put(self, data):
self.queue.put(data)
def stop(self):
elapsed = (timeit.default_timer()-self.startup)
print termcolor.colored(
"Thread was running for %10.4f seconds. %10.4f was spent processing or blocked. (%6.2f%%): %s" %
(round(elapsed, 4), round(self.time, 4), round((self.time / elapsed * 100), 2), self.address), 'red')
self.go = False
def stats(self):
elapsed = (timeit.default_timer()-self.startup)
print termcolor.colored(
"Thread running for %10.4f seconds. %10.4f has been spent processing or blocked. (%6.2f%%): %s" %
(round(elapsed, 4), round(self.time, 4), round((self.time / elapsed * 100), 2), self.address), 'red')
def parse(self, message):
return ""
def getLastMessageTime(self):
return self.last_message