Пример #1
0
    def test_init_env(self):
        # ---testing the values expected
        env = en.init_env(2, 2, (0, 0), (1, 1))
        self.assertAlmostEqual(env[1, 1], True)
        self.assertAlmostEqual(env[0, 0], True)
        self.assertAlmostEqual(env[0, 1], False)
        self.assertAlmostEqual(env[1, 0], False)

        # ---testing the types expected
        self.assertRaises(TypeError, en.init_env, 2, 2, 1, 1)
        self.assertRaises(TypeError, en.init_env, 2, 2, (1, 1), '(3, 3)')
        self.assertRaises(TypeError, en.init_env, 2, 2, (1, ))
        self.assertRaises(TypeError, en.init_env, -1, 2, (1, 1))
Пример #2
0
#coding=utf8
'''
    接收mq消息
'''
__author__ = 'guozhiwei'
import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
import env
env.init_env()

import tx_mq

from twisted.internet import reactor

if __name__ == '__main__':

    mq = tx_mq.txRabbitmq.get_instance()
    mq.init_for_worker()
    reactor.run()
Пример #3
0
#coding=utf8
'''
    tcp server主程序

        1. 新连接和连接的断开
        2. 收包和发包
        3. 建立延迟检测是否登陆的任务
'''
__author__ = 'guozhiwei'

import sys
import env
env.init_env()
import config

from twisted.internet import reactor
from twisted.internet import protocol
from twisted.internet.protocol import ServerFactory
import tcp_data_parser
import tx_mq


class ClientProtocol(protocol.Protocol):

    def connectionMade(self):
        '''
            当客户端有新的连接的时候,会自动调用该方法
        :return:
        '''
        self.recv_data_buffer = ''   #数据接受缓冲区
        self.is_sign_in = 0  #初始上来的时候没有登陆
Пример #4
0
                    choices=['cli', 'gui'])

args = parser.parse_args()

if not args.type: args.type = 'cli'

if not args.cells:
    args.cells = [(5, 1), (5, 2), (5, 3)]
else:
    args.cells = list(set(args.cells))
    args.cells = [(int(i[0]), int(i[2])) for i in args.cells]

if not args.generations: args.generations = 10
if not args.size: args.size = 10

env = en.init_env(args.size, args.size, args.cells)

if args.type == 'cli':
    # ---CLI version
    import os
    import time
    for g in range(args.generations):
        print('generation number ' + str(g))
        for i in range(10):
            for j in range(10):
                print('x', end='') if env[i, j] == True else print('.', end='')
            print()
        env = en.tick(env, env.shape[0], env.shape[1])
        time.sleep(1)
        os.system('clear')
else:
Пример #5
0
# -*- coding: utf-8 -*-
import sys
import env
import argparser
import build_android
import build_ios
import subprocess

builders = {
    'Android' : build_android.build,
    'iOS' : build_ios.build,
}

env = env.init_env()
args = argparser.parse()
print(args)

branch = subprocess.check_output('git rev-parse --abbrev-ref HEAD'.split()).strip()
args.branch = branch
print('branch: ' + branch)
rev = subprocess.check_output('git rev-parse HEAD'.split()).strip()
args.rev = rev
print('rev:    ' + rev)

builders[args.buildTarget](env, args)