fix: KingClient 添加日志4
This commit is contained in:
parent
1d4239c28a
commit
96e96ef8cc
|
@ -47,6 +47,8 @@ class KingClient(HandleLogMixin):
|
||||||
**kapis['login'], json=json, timeout=10, need_auth=False, raise_exception=False)
|
**kapis['login'], json=json, timeout=10, need_auth=False, raise_exception=False)
|
||||||
if is_ok == "success":
|
if is_ok == "success":
|
||||||
current_val = res['Authorization']
|
current_val = res['Authorization']
|
||||||
|
else:
|
||||||
|
myLogger.error(f'获取token失败: {is_ok}-{res}')
|
||||||
cache.set('king_token', current_val, timeout=None)
|
cache.set('king_token', current_val, timeout=None)
|
||||||
return is_ok, current_val
|
return is_ok, current_val
|
||||||
|
|
||||||
|
@ -77,11 +79,11 @@ class KingClient(HandleLogMixin):
|
||||||
ret = r.json()
|
ret = r.json()
|
||||||
if 'code' in ret:
|
if 'code' in ret:
|
||||||
if ret['code'] != 0:
|
if ret['code'] != 0:
|
||||||
if need_auth and ret['code'] in [-1, -2] and ret['message'] != 'failed': # 认证失败
|
if need_auth and ret['code'] in [-1, -2] and url != '/api/v1/variables': # 认证失败
|
||||||
# 如果这里没有判断准确,可能会导致多次触发login
|
# 如果这里没有判断准确,可能会导致多次触发login
|
||||||
myLogger.error(f"亚控认证失败: {url}-{ret}")
|
myLogger.error(f"亚控认证失败: {self.headers}-{url}-{ret}")
|
||||||
is_ok, _ = self._get_token()
|
is_ok, _ = self._get_token()
|
||||||
if is_ok:
|
if is_ok == "success":
|
||||||
return self.request(url, method, params, json, timeout, raise_exception, need_auth)
|
return self.request(url, method, params, json, timeout, raise_exception, need_auth)
|
||||||
|
|
||||||
err_detail = dict(detail=f"亚控错误: {ret['message']}",
|
err_detail = dict(detail=f"亚控错误: {ret['message']}",
|
||||||
|
|
Loading…
Reference in New Issue