def dispatcher(self, sock, data): """just enclosure of CMD dispatcher""" try: CMD.dispatcher(self, sock, data) except Exception as e: self.logger.error('unknow message: %s from %s'%(data, self.node.sockets[sock])) self.logger.exception("\n----------------\n the error is: \n" + \ str(e) + \ "\n----------------\n") self.node.send(sock, 'you have sent me a unknown message')
def dispatcher(self, sock, data): """just enclosure of CMD dispatcher""" try: CMD.dispatcher(self, sock, data) except Exception as e: self.logger.error('unknow message: %s from %s' % (data, self.node.sockets[sock])) self.logger.exception("\n----------------\n the error is: \n" + \ str(e) + \ "\n----------------\n") self.node.send(sock, 'you have sent me a unknown message')
def __init__(self, desc=server_desc): CMD.__init__(self, desc)
# coding:utf-8 import requests import json from CMD import CMD if __name__ == '__main__': url = 'http://127.0.0.1:8000/cmd/' headers = {'Content-Type': 'application/json'} # data = {"cmd": "coco", "act": 0, "data": "你好", "duration": 5, "dir": 3} data = CMD.getAnimData(5, 5, 5) data = json.dumps(data) print(data) requests.post(url, headers=headers, data=data)
def __init__(self, desc=None): """initialization of ClientCMD""" CMD.__init__(self, desc)