style: 统一 Ruff 代码格式
This commit is contained in:
@@ -19,15 +19,24 @@ from .huya_runner_recharge import RechargeMixin
|
||||
|
||||
|
||||
class HuyaBatchRunner(
|
||||
HuyaBatchRunnerCore, BindMixin, GoodsMixin, RechargeMixin,
|
||||
HuyaBatchRunnerCore,
|
||||
BindMixin,
|
||||
GoodsMixin,
|
||||
RechargeMixin,
|
||||
):
|
||||
"""批量执行虎牙任务(功能域 Mixin 聚合 + 批次调度)。"""
|
||||
|
||||
def _execute_one(self, task_id: int, account_info: dict, config_info: dict, total: int):
|
||||
def _execute_one(
|
||||
self, task_id: int, account_info: dict, config_info: dict, total: int
|
||||
):
|
||||
worker_db = SessionLocal()
|
||||
try:
|
||||
task = worker_db.query(HuyaTask).filter(HuyaTask.id == task_id).first()
|
||||
account = worker_db.query(HuyaAccount).filter(HuyaAccount.id == account_info["account_id"]).first()
|
||||
account = (
|
||||
worker_db.query(HuyaAccount)
|
||||
.filter(HuyaAccount.id == account_info["account_id"])
|
||||
.first()
|
||||
)
|
||||
if not task or not account:
|
||||
return
|
||||
|
||||
@@ -59,28 +68,48 @@ class HuyaBatchRunner(
|
||||
"create_recharge_order",
|
||||
}:
|
||||
self._mark_task(worker_db, task, "failed", "该虎牙任务执行器暂未实现")
|
||||
self._push_log("warning", f"[{current}] {name} 暂未实现: {self.task_type}")
|
||||
self._push_log(
|
||||
"warning", f"[{current}] {name} 暂未实现: {self.task_type}"
|
||||
)
|
||||
return
|
||||
|
||||
try:
|
||||
if self.task_type == "query_points":
|
||||
self._execute_query_points(worker_db, task, account, account_info, config_info)
|
||||
self._execute_query_points(
|
||||
worker_db, task, account, account_info, config_info
|
||||
)
|
||||
elif self.task_type == "refresh_goods":
|
||||
self._execute_refresh_goods(worker_db, task, account, account_info, config_info)
|
||||
self._execute_refresh_goods(
|
||||
worker_db, task, account, account_info, config_info
|
||||
)
|
||||
elif self.task_type == "refresh_recharge_goods":
|
||||
self._execute_refresh_recharge_goods(worker_db, task, account, account_info, config_info)
|
||||
self._execute_refresh_recharge_goods(
|
||||
worker_db, task, account, account_info, config_info
|
||||
)
|
||||
elif self.task_type == "exchange_goods":
|
||||
self._execute_exchange_goods(worker_db, task, account, account_info, config_info)
|
||||
self._execute_exchange_goods(
|
||||
worker_db, task, account, account_info, config_info
|
||||
)
|
||||
elif self.task_type == "create_recharge_order":
|
||||
self._execute_create_recharge_order(worker_db, task, account, account_info, config_info)
|
||||
self._execute_create_recharge_order(
|
||||
worker_db, task, account, account_info, config_info
|
||||
)
|
||||
elif self.task_type == "get_bind_qr":
|
||||
self._execute_get_bind_qr(worker_db, task, account, account_info, config_info)
|
||||
self._execute_get_bind_qr(
|
||||
worker_db, task, account, account_info, config_info
|
||||
)
|
||||
elif self.task_type == "confirm_bind":
|
||||
self._execute_confirm_bind(worker_db, task, account, account_info, config_info)
|
||||
self._execute_confirm_bind(
|
||||
worker_db, task, account, account_info, config_info
|
||||
)
|
||||
elif self.task_type == "query_game_name":
|
||||
self._execute_query_game_name(worker_db, task, account, account_info, config_info)
|
||||
self._execute_query_game_name(
|
||||
worker_db, task, account, account_info, config_info
|
||||
)
|
||||
elif self.task_type == "query_exchange_records":
|
||||
self._execute_query_exchange_records(worker_db, task, account, account_info, config_info)
|
||||
self._execute_query_exchange_records(
|
||||
worker_db, task, account, account_info, config_info
|
||||
)
|
||||
worker_db.refresh(task)
|
||||
if task.status == "success":
|
||||
self._push_log("success", f"[{current}] {name} {task.message}")
|
||||
@@ -124,17 +153,19 @@ class HuyaBatchRunner(
|
||||
task.status = "pending"
|
||||
task.message = "等待执行"
|
||||
task.finished_at = None
|
||||
task_infos.append({
|
||||
"task_id": task.id,
|
||||
"account_info": {
|
||||
"account_id": account.id,
|
||||
"uid": account.uid or "",
|
||||
"yyuid": account.yyuid or "",
|
||||
"username": account.username or "",
|
||||
"nickname": account.nickname or "",
|
||||
"cookie": normalize_huya_cookie(account.cookie or ""),
|
||||
},
|
||||
})
|
||||
task_infos.append(
|
||||
{
|
||||
"task_id": task.id,
|
||||
"account_info": {
|
||||
"account_id": account.id,
|
||||
"uid": account.uid or "",
|
||||
"yyuid": account.yyuid or "",
|
||||
"username": account.username or "",
|
||||
"nickname": account.nickname or "",
|
||||
"cookie": normalize_huya_cookie(account.cookie or ""),
|
||||
},
|
||||
}
|
||||
)
|
||||
self.db.commit()
|
||||
|
||||
total = len(task_infos)
|
||||
@@ -149,13 +180,15 @@ class HuyaBatchRunner(
|
||||
if self._stop.is_set():
|
||||
self._push_log("warning", "任务已停止,跳过剩余账号")
|
||||
break
|
||||
futures.append(executor.submit(
|
||||
self._execute_one,
|
||||
item["task_id"],
|
||||
item["account_info"],
|
||||
config_info,
|
||||
total,
|
||||
))
|
||||
futures.append(
|
||||
executor.submit(
|
||||
self._execute_one,
|
||||
item["task_id"],
|
||||
item["account_info"],
|
||||
config_info,
|
||||
total,
|
||||
)
|
||||
)
|
||||
|
||||
for future in as_completed(futures):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user