This commit is contained in:
毛鹏
2025-11-28 20:25:39 +08:00
parent b74f19590a
commit d41c502577
2 changed files with 5 additions and 4 deletions

View File

@@ -33,7 +33,7 @@ async def process(parent, is_login=False, retry=0):
from src.network import HTTP
from src.settings import settings
from mangotools.data_processor import EncryptionTool
HTTP.not_auth.login(SetConfig.get_username(), SetConfig.get_password()) # type:
HTTP.not_auth.login(SetConfig.get_username(), SetConfig.get_password(), is_retry=True) # type:
retry = 0
except Exception as error:
if websocket_task:

View File

@@ -64,24 +64,25 @@ class HttpClientApi(HttpBase):
cls.login(SetConfig.get_username(), SetConfig.get_password()) # type: ignore
@classmethod
def login(cls, username: str = None, password=None, retry=0):
def login(cls, username: str = None, password=None, retry=0, is_retry=False):
try:
response = cls.post('/login', data={
'username': username,
'password': EncryptionTool.md5_32_small(password),
'version': settings.SETTINGS.get('version')
})
print('登录', retry, response)
if response.data and response.code == 200:
log.info(response.model_dump())
cls.headers['Authorization'] = response.data.get('token')
if is_retry and retry < 100:
return cls.login(username, password, retry + 1, is_retry)
return response
except Exception as error:
print(settings.IS_OPEN and retry < 100)
if settings.IS_OPEN and retry < 100:
time.sleep(3)
log.info(f'开始登录重试:{retry}{error}')
return cls.login(username, password, retry + 1)
return cls.login(username, password, retry + 1, is_retry)
else:
raise error