bugfix
This commit is contained in:
parent
e7420545b2
commit
0355fb5cc3
@ -18,8 +18,6 @@ class ArgsConvert(object):
|
|||||||
|
|
||||||
def convert(self,obj,namespace,default=''):
|
def convert(self,obj,namespace,default=''):
|
||||||
""" obj can be a string,[],or dictionary """
|
""" obj can be a string,[],or dictionary """
|
||||||
if type(obj) == type(u''):
|
|
||||||
return self.convertUnicode(obj,namespace,default)
|
|
||||||
if type(obj) == type(''):
|
if type(obj) == type(''):
|
||||||
return self.convertString(obj,namespace,default)
|
return self.convertString(obj,namespace,default)
|
||||||
if type(obj) == type([]):
|
if type(obj) == type([]):
|
||||||
@ -58,21 +56,19 @@ class ArgsConvert(object):
|
|||||||
return default
|
return default
|
||||||
return v
|
return v
|
||||||
|
|
||||||
def convertUnicode(self,s,namespace,default):
|
def convertString(self,s,namespace,default):
|
||||||
args = re.findall(self.re1,s)
|
args = re.findall(self.re1,s)
|
||||||
for arg in args:
|
for arg in args:
|
||||||
dl = s.split(arg)
|
dl = s.split(arg)
|
||||||
var = self.getVarName(arg)
|
var = self.getVarName(arg)
|
||||||
v = self.getVarValue(var,namespace,default)
|
v = self.getVarValue(var,namespace,default)
|
||||||
if type(v) != type(u''):
|
if type(v) != type(u''):
|
||||||
|
if len(args) == 1 and s.startswith(self.preString) and s.endswith(self.subfixString):
|
||||||
|
return v
|
||||||
v = str(v)
|
v = str(v)
|
||||||
s = v.join(dl)
|
s = v.join(dl)
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def convertString(self,s,namespace,default):
|
|
||||||
ret = self.convertUnicode(s,namespace,default)
|
|
||||||
return ret
|
|
||||||
|
|
||||||
class ConditionConvert(object):
|
class ConditionConvert(object):
|
||||||
def __init__(self,pString = u'$<',sString=u'>$',coding='utf-8'):
|
def __init__(self,pString = u'$<',sString=u'>$',coding='utf-8'):
|
||||||
self.coding = coding
|
self.coding = coding
|
||||||
|
@ -59,18 +59,27 @@ class HttpClient:
|
|||||||
response_type=RESPONSE_TEXT,
|
response_type=RESPONSE_TEXT,
|
||||||
params=None,
|
params=None,
|
||||||
data=None,
|
data=None,
|
||||||
json=None,
|
jd=None,
|
||||||
headers=None,
|
headers=None,
|
||||||
**kw):
|
**kw):
|
||||||
session = self.getsession(url)
|
session = self.getsession(url)
|
||||||
|
if params == {}:
|
||||||
|
params = None
|
||||||
|
if data == {}:
|
||||||
|
data = None
|
||||||
|
if jd == {}:
|
||||||
|
jd = None
|
||||||
|
if headers == {}:
|
||||||
|
headers = None
|
||||||
|
|
||||||
resp = await session.request(method, url,
|
resp = await session.request(method, url,
|
||||||
params=params,
|
params=params,
|
||||||
data=data,
|
data=data,
|
||||||
json=json,
|
json=jd,
|
||||||
headers=headers, **kw)
|
headers=headers, **kw)
|
||||||
if resp.status==200:
|
if resp.status==200:
|
||||||
return await self.handleResp(url, resp, response_type)
|
return await self.handleResp(url, resp, response_type)
|
||||||
return None
|
raise Exception(f'http error({resp.status}, {url=},{params=}, {data=}, {jd=}, {headers=}, {kw=})')
|
||||||
|
|
||||||
async def get(self,url,**kw):
|
async def get(self,url,**kw):
|
||||||
return self.request(url, 'GET', **kw)
|
return self.request(url, 'GET', **kw)
|
||||||
|
@ -30,12 +30,12 @@ class OAuthClient:
|
|||||||
url = d.get('url')
|
url = d.get('url')
|
||||||
_params = self.datalize(myparams, params)
|
_params = self.datalize(myparams, params)
|
||||||
_headers = self.datalize(headers, params)
|
_headers = self.datalize(headers, params)
|
||||||
_data = self.datalize(data, params)
|
_data = self.datalize(mydata, params)
|
||||||
response_type = d.get('response_type', RESPONSE_JSON)
|
response_type = d.get('response_type', RESPONSE_JSON)
|
||||||
hc = HttpClient()
|
hc = HttpClient()
|
||||||
resp_data = await hc.request(url, method, response_type=response_type,
|
resp_data = await hc.request(url, method, response_type=response_type,
|
||||||
params=_params,
|
params=_params,
|
||||||
data=_data,
|
data=None if _data == {} else json.dumps(_data),
|
||||||
headers=_headers)
|
headers=_headers)
|
||||||
if resp_data is None:
|
if resp_data is None:
|
||||||
raise Exception(f'request error:{url=}\n{method=}\n{response_type=}\n{_params=}\n{_headers=}')
|
raise Exception(f'request error:{url=}\n{method=}\n{response_type=}\n{_params=}\n{_headers=}')
|
||||||
|
Loading…
Reference in New Issue
Block a user