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


Python Game.get方法代码示例

本文整理汇总了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
开发者ID:Mordeaux,项目名称:Setback,代码行数:10,代码来源:views.py

示例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
开发者ID:StarsGame,项目名称:hlstats-py,代码行数:78,代码来源:LogParser.py


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