feat: 添加基建配置文件设置接口
This commit is contained in:
@@ -829,6 +829,26 @@ class AppConfig(GlobalConfig):
|
||||
await script_config.UserData.setOrder([uuid.UUID(_) for _ in index_list])
|
||||
await self.ScriptConfig.save()
|
||||
|
||||
async def set_infrastructure(
|
||||
self, script_id: str, user_id: str, jsonFile: str
|
||||
) -> None:
|
||||
|
||||
logger.info(f"{script_id} - {user_id} 设置基建配置:{jsonFile}")
|
||||
|
||||
json_path = Path(jsonFile)
|
||||
|
||||
if not json_path.exists():
|
||||
raise FileNotFoundError(f"File not found: {json_path}")
|
||||
|
||||
(Path.cwd() / f"data/{script_id}/{user_id}/Infrastructure").mkdir(
|
||||
parents=True, exist_ok=True
|
||||
)
|
||||
shutil.copy(
|
||||
json_path,
|
||||
Path.cwd()
|
||||
/ f"data/{script_id}/{user_id}/Infrastructure/infrastructure.json",
|
||||
)
|
||||
|
||||
async def add_plan(
|
||||
self, script: Literal["MaaPlan"]
|
||||
) -> tuple[uuid.UUID, ConfigBase]:
|
||||
|
||||
@@ -230,12 +230,14 @@ class _TaskManager:
|
||||
|
||||
logger.info(f"中止任务:{task_id}")
|
||||
|
||||
uid = uuid.UUID(task_id)
|
||||
|
||||
if uid not in self.task_dict:
|
||||
raise ValueError(f"The task {uid} is not running.")
|
||||
|
||||
self.task_dict[uid].cancel()
|
||||
if task_id == "ALL":
|
||||
for task in self.task_dict.values():
|
||||
task.cancel()
|
||||
else:
|
||||
uid = uuid.UUID(task_id)
|
||||
if uid not in self.task_dict:
|
||||
raise ValueError(f"The task {uid} is not running.")
|
||||
self.task_dict[uid].cancel()
|
||||
|
||||
async def remove_task(
|
||||
self, task: asyncio.Task, mode: str, task_id: uuid.UUID
|
||||
|
||||
Reference in New Issue
Block a user