代码优化

This commit is contained in:
liujianjiang 2026-01-09 11:12:14 +08:00
parent 038495f226
commit 9e76be1976
4 changed files with 20 additions and 14 deletions

View File

@ -114,6 +114,7 @@ class DealAccount:
# 下载执行脚本 # 下载执行脚本
self.task_all.upload_file_to_phone([data["pad_code"]], file_name=res_dict["script_name"]) self.task_all.upload_file_to_phone([data["pad_code"]], file_name=res_dict["script_name"])
# 设置代理 # 设置代理
print(data)
self.task_all.set_network_proxy(pad_code=[data["pad_code"]],country=data["country"]) self.task_all.set_network_proxy(pad_code=[data["pad_code"]],country=data["country"])
# 启动对应脚本 # 启动对应脚本
self.task_all.async_execute_adb_command(pad_code=data["pad_code"], file_name=res_dict["script_name"]) self.task_all.async_execute_adb_command(pad_code=data["pad_code"], file_name=res_dict["script_name"])

View File

@ -221,10 +221,11 @@ async def shop_backup(backup_data: BackupItem, account_manager: Any = Depends(ge
pad_code pad_code
""" """
param = backup_data.model_dump() param = backup_data.model_dump()
try: print(param)
result = await account_manager.deal_backup_task(param) result = await account_manager.deal_backup_task(param)
if param.get("is_restore", False): if param.get("is_restore", False):
time.sleep(random.randint(1, 10)) time.sleep(random.randint(1, 10))
print(param)
restore_result = await account_manager.deal_restore_system(param) restore_result = await account_manager.deal_restore_system(param)
if restore_result and result: if restore_result and result:
return {"code": 200, "message": f"任务:{param.get("pad_code")} 备份还原成功"} return {"code": 200, "message": f"任务:{param.get("pad_code")} 备份还原成功"}
@ -234,8 +235,10 @@ async def shop_backup(backup_data: BackupItem, account_manager: Any = Depends(ge
return {"code": 200, "message": f"任务:{param.get("pad_code")} 备份成功", } return {"code": 200, "message": f"任务:{param.get("pad_code")} 备份成功", }
else: else:
raise HTTPException(status_code=404, detail=f"云机:{param.get("pad_code")} 备份失败") raise HTTPException(status_code=404, detail=f"云机:{param.get("pad_code")} 备份失败")
except Exception as e: # try:
raise HTTPException(status_code=404, detail=f"云机:{param.get("pad_code")} 备份失败,失败原因:{e}") # pass
# except Exception as e:
# raise HTTPException(status_code=404, detail=f"云机:{param.get("pad_code")} 备份失败,失败原因:{e}")
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -59,3 +59,4 @@ class BackupItem(BaseModel):
account_id: str = Field(..., description="账号ID") account_id: str = Field(..., description="账号ID")
script_name: str = Field(..., description="脚本名称") script_name: str = Field(..., description="脚本名称")
is_restore: bool = Field(..., description="是否还原") is_restore: bool = Field(..., description="是否还原")
country: bool = Field(..., description="国家")

View File

@ -138,6 +138,7 @@ class DealAllTask:
def check_phone_status(self, pad_code: list[str], file_name: str,times=10): def check_phone_status(self, pad_code: list[str], file_name: str,times=10):
count = 0 count = 0
time.sleep(300)
while True: while True:
result = self.async_execute_adb_command(pad_code, file_name, is_check=True) result = self.async_execute_adb_command(pad_code, file_name, is_check=True)
if result: if result: