Ejemplo n.º 1
0
def sys_init():
    # sys log init
    global LOG
    LOG = MyLogger(os.path.abspath(sys.argv[0]).replace(
        'py', 'log'), clevel=logging.DEBUG, renable=False)
    global cprint
    cprint = cprint(os.path.abspath(sys.argv[0]).replace('py', 'log'))

    # cmd arg init
    global arg_handle
    arg_handle = ArgHandle()
    arg_handle.run()
    LOG.info("Let's go!!!")
Ejemplo n.º 2
0
def sys_init():
    global LOG
    LOG = MyLogger(os.path.abspath(sys.argv[0]).replace('py', 'log'), clevel=logging.INFO,
                   rlevel=logging.WARN)
    global cprint
    cprint = cprint(__name__)

    global arg_handle
    arg_handle = ArgHandle()
    arg_handle.run()

    global thread_list
    thread_list = []
    LOG.info("Let's go!!!")
Ejemplo n.º 3
0
    def send_data(self, data):
        return self.connection.send_once(data)

    def recv_data(self):
        datas = self.connection.recv_once()
        return datas


# 空调遥控器模拟程序入口
if __name__ == '__main__':
    # sys log init
    LOG = MyLogger(os.path.abspath(sys.argv[0]).replace('py', 'log'),
                   clevel=logging.INFO,
                   renable=False)

    cprint = cprint(os.path.abspath(sys.argv[0]).replace('py', 'log'))

    # cmd arg init
    arg_handle = ArgHandle()
    arg_handle.run()

    # sys init
    sys_init()

    # multi thread
    global thread_list
    thread_list = []

    app = AirControl(
        (arg_handle.get_args('server_IP'), arg_handle.get_args('server_port')),
        logger=LOG)
Ejemplo n.º 4
0
def sys_init():
    LOG.info("Let's go!!!")


# 系统清理函数,系统退出前调用
def sys_cleanup():
    LOG.info("Goodbye!!!")


# 主程序入口
if __name__ == '__main__':
    # sys log init
    LOG = MyLogger(os.path.abspath(sys.argv[0]).replace('py', 'log'),
                   clevel=logging.DEBUG,
                   rlevel=logging.WARN)
    cprint = cprint(__name__)

    # sys init
    sys_init()

    # cmd arg init
    arg_handle = ArgHandle()
    arg_handle.run()

    # multi thread
    global thread_list
    thread_list = []

    # create serial objs
    global coms_list
    coms_list = {}
Ejemplo n.º 5
0
        except Exception as e:
            LOG.error('error: ' + str(e))

    try:
        return (r.status_code, r.json(), r.headers)
    except json.decoder.JSONDecodeError:
        return (r.status_code, r.text, r.headers)
    except:
        return (400, {}, {})


if __name__ == "__main__":
    global LOG
    global cprint
    global arg_handle
    cprint = cprint()
    arg_handle = ArgHandle()
    arg_handle.run()

    LOG = MyLogger(os.path.abspath(sys.argv[0]).replace(
        'py', 'log'), clevel=logging.DEBUG, fenable=False)
    picpath = "pics"
    if not os.path.exists(picpath):
        LOG.error('no pics dir!!!')
        sys.exit()

    msg = {
        "name": "小狗狗test",
        "userType": "1",
        "sex": "1",
        "idenType": "111",