def quickDebug(request): addr = request.POST.get("addr") addrList = addr.split(":") service = request.POST.get("service") method = request.POST.get("method") params = request.POST.get("params") encoding = request.POST.get("encoding", "gb18030") print("1111 %s" % encoding) cmd = "invoke %s.%s(%s)" % (service, method, params) retMsg = DubboInterfaceService.do_telnet(addrList[0], addrList[1], cmd, encoding=encoding) retMsg = retMsg.replace("\r\ndubbo>", "") bodyDict = {} if "elapsed:" in retMsg: msgList = retMsg.split("elapsed:") bodyDict['actualMsg'] = msgList[0] bodyDict['taketime'] = int(msgList[1].split("ms")[0].strip()) else: bodyDict['actualMsg'] = retMsg bodyDict['taketime'] = 0 if "TELNET_ERROR: Telnet请求时发生网络问题或者接口错误,请确认。" not in retMsg: id = DubboInterfaceService.addQuickDebugData( addr, service, method, params, bodyDict['actualMsg'], bodyDict['taketime'], request.session.get("loginName"), encoding=encoding) bodyDict['id'] = id return HttpResponse(ApiReturn(ApiReturn.CODE_OK, "成功!", bodyDict).toJson())
def doTelnetCommand(request): addr = request.POST.get("addr") addrList = addr.split(":") encoding = request.POST.get("encoding","gb18030") print("1111 %s" % encoding) cmd = request.POST.get("params") retMsg = DubboInterfaceService.do_telnet(addrList[0],addrList[1],cmd,encoding=encoding) retMsg = retMsg.replace("\r\ndubbo>","") bodyDict = {} if "elapsed:" in retMsg: msgList = retMsg.split("elapsed:") bodyDict['actualMsg'] = msgList[0] bodyDict['taketime'] = int(msgList[1].split("ms")[0].strip()) else: bodyDict['actualMsg'] = retMsg bodyDict['taketime'] = 0 return HttpResponse(ApiReturn(ApiReturn.CODE_OK, "成功!", bodyDict).toJson())