mirror of
https://gitee.com/mao-peng/MangoTestingPlatform.git
synced 2025-12-06 11:59:15 +08:00
优化
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user