Skip to content

Commit

Permalink
raname raise_error_log
Browse files Browse the repository at this point in the history
  • Loading branch information
lemisky committed Jan 19, 2024
1 parent a343b50 commit 6daed6f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/aligo/core/Auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def debug_log(self, response: requests.Response):
self.log.warning(f'[url] {response.url}')
self.log.warning(f'[response body] {response.text[:200]}')

def error_log_exit(self, response: requests.Response):
def raise_error_log(self, response: requests.Response):
"""打印错误日志并退出"""
self.debug_log(response)
# exit(-1)
Expand Down Expand Up @@ -251,7 +251,7 @@ def _login(self):

if response.status_code != 200:
self.log.error('登录失败')
self.error_log_exit(response)
self.raise_error_log(response)

bizExt = response.json()['content']['data']['bizExt']
bizExt = base64.b64decode(bizExt).decode('gb18030')
Expand Down Expand Up @@ -320,7 +320,7 @@ def _login_by_qrcode(self) -> requests.Response:
return response
else:
self.log.warning('未知错误 可能二维码已经过期')
self.error_log_exit(response)
self.raise_error_log(response)
time.sleep(3)
self._login_timeout.check_timeout()

Expand Down Expand Up @@ -351,7 +351,7 @@ def _refresh_token(self, refresh_token=None, loop_call: bool = False):
elif response.status_code == 502:
if loop_call:
self.log.warning('刷新 token 失败')
self.error_log_exit(response)
self.raise_error_log(response)
self.log.warning('刷新 token 时出现 502 网关错误,暂停10秒后重试')
time.sleep(10)
return self._refresh_token(refresh_token=refresh_token, loop_call=True)
Expand All @@ -360,7 +360,7 @@ def _refresh_token(self, refresh_token=None, loop_call: bool = False):
if loop_call:
# 从 _login 调用,则不继续调用 _login,防止循环调用
# 走到这里 说明 登录失败,则 退出
self.error_log_exit(response)
self.raise_error_log(response)
else:
self.debug_log(response)
if self._re_login:
Expand Down Expand Up @@ -445,7 +445,7 @@ def request(self, method: str, url: str, params: Dict = None,
return response

self.log.info(f'重试 5 次仍失败,抛出异常')
self.error_log_exit(response)
self.raise_error_log(response)

def get(self, path: str, host: str = API_HOST, params: dict = None, headers: dict = None) -> requests.Response:
"""..."""
Expand Down

0 comments on commit 6daed6f

Please sign in to comment.