boxAgent.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:Mohou_Box-master 作者: mohou 项目源码 文件源码
def handleOperate(cmd):
    logging.info("handleOperate: Start to handle operate. cmd=%s", str(cmd))

    url = client.protocol + client.localHostPort + "/command"
    command = {"type": cmd['type'],
               "boxid": cmd['boxid'],
               "data": "",
               }
    del cmd['type']
    command['data'] = json.dumps(cmd)
    headers, body = createFormData(command)
    operate_request = HTTPRequest(url=url, method="POST", headers=headers, body=body)
    response = yield client.http_client.fetch(operate_request, request_timeout=60)
    if response.error:
        logging.error("handleOperate: Failed to send operate. error=%s", response.error)
    else:
        logging.info("handleOperate: Operate result. response.body=%r", response.body)
        res = json_decode(response.body)
        if res["ret_value"] != 0:
            #need login
            logging.warn("handleOperate: Failed to execute [%s] operation. ret_val=", res["ret_value"])

    logging.info("handleOperate: End to handle operate.")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号