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