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


Python Server.clients方法代码示例

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


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

示例1: test_clients

# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import clients [as 别名]
	def test_clients(self) :
		s = Server("fixture")
		s.createServer()
		s.createProject("project1")
		s.createClient("project1","client1-1")
		s.createProject("project2")
		s.createClient("project2","client2-1")
		s.createClient("project2","client2-2")
		self.assertEqual(s.clients("project2"), [
			'client2-1',
			'client2-2',
			])
开发者ID:clam-project,项目名称:testfarm-server2,代码行数:14,代码来源:server_test.py

示例2: main

# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import clients [as 别名]

#.........这里部分代码省略.........
                #TODO: save screenshot
                gui.set_status_stats(False)
                gui.set_status_game(False)
                gui.set_stats({})
                continue

            # =========================================
            #  Stats
            # =========================================

            try:
                results = get_stats(screenshot)
            except:
                #TODO: save screenshot
                results = None
                
            if results is None:
                gui.set_status_stats(False)
                gui.set_stats({})
                continue

            # =========================================
            #  Stats Exist!
            # =========================================

            if not game_started:
                game_started = True
                socket_server.send({ 'event': 'game_started' })

            gui.set_status_stats(True)
            gui.set_stats(results)

            if results['team_kills'] > 200 or results['team_deaths'] > 200 or results['kills'] > 200:
                broken += 1
                screenshot.image.save('broken{}.bmp'.format(broken))

            # =========================================
            #  Events
            # =========================================

            if last_results and results:

                diff_cs = results['CS'] - last_results['CS']
                diff_kills = results['kills'] - last_results['kills']
                diff_deaths = results['deaths'] - last_results['deaths']
                diff_team_kills = results['team_kills'] - last_results['team_kills']
                diff_team_deaths = results['team_deaths'] - last_results['team_deaths']

                if diff_team_kills < 0 or diff_team_deaths < 0 or diff_kills < 0:
                    broken += 1
                    screenshot.image.save('broken_before_{}.bmp'.format(broken))
                    last_screenshot.image.save('broken_after_{}.bmp'.format(broken))


                if diff_cs > 0:
                    socket_server.send({ 'event': 'cs', 'amount': diff_cs, 'total': results['CS'] })

                if diff_kills:
                    time_now = time()
                    time_since_last = time_now - kill_spree[0]

                    if time_since_last <= 10.5:
                        kill_spree = (time_now, kill_spree[1]+diff_kills)
                    else:
                        kill_spree = (time_now, 1)

                    kills = kill_spree[1]

                    socket_server.send({ 'event': 'kill', 'total': results['kills'], 'streak': kills })

                elif diff_team_kills:
                    socket_server.send({ 'event': 'team_kill', 'amount': diff_team_kills, 'total': results['team_kills'] })

                if diff_deaths:
                    socket_server.send({ 'event': 'death', 'total': results['deaths'] })
                elif diff_team_deaths:
                    socket_server.send({ 'event': 'team_death', 'amount': diff_team_deaths, 'total': results['team_deaths'] })

            last_results = results
            last_screenshot = screenshot

        # =========================================
        #  Missing Window
        # =========================================

        else:
            if game_started:
                game_started = False
                last_results = None
                socket_server.send({ 'event': 'game_finished' })

            if game_open:
                game_open = False

            gui.set_status_game(False)
            gui.set_stats({})

        gui.set_status_clients(len(socket_server.clients()))

    socket_server.stop()
开发者ID:suentiem,项目名称:League-Stats,代码行数:104,代码来源:main.py


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