本文整理汇总了Python中remote_connection.RemoteConnection.setHeaders方法的典型用法代码示例。如果您正苦于以下问题:Python RemoteConnection.setHeaders方法的具体用法?Python RemoteConnection.setHeaders怎么用?Python RemoteConnection.setHeaders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类remote_connection.RemoteConnection
的用法示例。
在下文中一共展示了RemoteConnection.setHeaders方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: HecomMockClient
# 需要导入模块: from remote_connection import RemoteConnection [as 别名]
# 或者: from remote_connection.RemoteConnection import setHeaders [as 别名]
class HecomMockClient(object):
def __init__(self,server,clientType,tid,version='6.0'):
#版本不一样,支持的命令是不一样的
#self.clientRsphandler=RspHandler() # result 非0全部抛异常
#self.paramChecker=
#self.rsp_handler=RspHandler()
#日志模块
#self.LOG=
self._host=server
self._version=version
self._clientType=clientType
self._tid=tid
self._headers={"version":self._version,"tid":self._tid,"clientType":self._clientType}
self.command_executor=RemoteConnection(server,self._headers)
def handle_response(self,rsp,exceptcode= '0'):
if rsp.status_code!=200 :
rsp.raise_for_status()
#判断是非为json数据
try:
jsonRsp=rsp.json()
except:
raise RuntimeError( "decode json failed")
else:
logging.info('Got Response : %s' % jsonRsp)
if jsonRsp['result']!= exceptcode :
raise RuntimeError("command execute failed: %s return resultcode %s desc %s" % (self.currentCommand,jsonRsp['result'],jsonRsp['desc']))
return jsonRsp
def login(self,telPhone,pwd):
#要把header中的sessionid存下来
m=hashlib.md5()
m.update(pwd)
pwd=m.hexdigest()
account={"telPhone":telPhone,"password":pwd}
rsp = self.execute(Command.LOGIN,userStr=account)
jsonRsp = self.handle_response(Command.LOGIN,rsp)
#rsp.raise_for_status()
if jsonRsp.has_key('data') :
self._accountInfo=jsonRsp['data']
#print self._accountInfo
logging.info('accountInfo %s ' % (self._accountInfo))
self._headers["entCode"]=self._accountInfo["entCode"]
self._headers["loginId"]=self._accountInfo["imLoginId"]
self._headers["uid"]=self._accountInfo["uid"]
self._headers["sessionId"]=self._accountInfo["sessionId"]
self.command_executor.setHeaders(self._headers)
logging.info('headers change %s' % (self._headers))
return self._accountInfo
raise RuntimeError("get accountInfo Failed" )
return jsonRsp
#self.command_executor.setHeader(self._header)
#测试通过
def logout(self,apiArgs):
rsp =self.execute(Command.LOGOUT,userStr=apiArgs)
return self.handle_response(rsp)
def verificationPhone(self, apiArgs):
rsp =self.execute(Command.VERIFICATION_PHONE,userStr=apiArgs)
return self.handle_response(rsp,exceptcode='3')
def registerUser(self, apiArgs):
rsp =self.execute(Command.REGISTER_USER,userStr=apiArgs)
return self.handle_response(rsp)
def registerEnt(self, apiArgs):
rsp =self.execute(Command.REGISTER_ENT,userStr=apiArgs)
return self.handle_response(rsp)
def updateEnt(self, apiArgs):
rsp =self.execute(Command.UPDATE_ENT,userStr=apiArgs)
return self.handle_response(rsp)
def getEntDetail(self, apiArgs):
rsp =self.execute(Command.GET_ENT_DETAIL,userStr=apiArgs)
return self.handle_response(rsp)
def joinEnt(self, apiArgs):
rsp =self.execute(Command.JOIN_ENT,userStr=apiArgs)
return self.handle_response(rsp)
def examineJoinUser(self, apiArgs):
rsp =self.execute(Command.EXAMINE_JOIN_USER,userStr=apiArgs)
return self.handle_response(rsp)
def removeUser(self, apiArgs):
rsp =self.execute(Command.REMOVE_USER,userStr=apiArgs)
return self.handle_response(rsp)
def addDept(self, apiArgs):
rsp =self.execute(Command.ADD_DEPT,userStr=apiArgs)
#.........这里部分代码省略.........