完成 Ruff 全量清理
This commit is contained in:
@@ -109,7 +109,7 @@ def decrypt_value(value: str | None) -> str | None:
|
||||
for candidate in _key_candidates():
|
||||
try:
|
||||
return _decrypt_with_candidate(value, candidate)
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
last_error = exc
|
||||
raise ValueError(
|
||||
"敏感字段解密失败,请确认 APP_ENCRYPTION_KEY 是否正确"
|
||||
@@ -124,7 +124,7 @@ def decrypt_value_with_key_name(value: str) -> tuple[str, str]:
|
||||
for candidate in _key_candidates():
|
||||
try:
|
||||
return _decrypt_with_candidate(value, candidate), candidate.name
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
last_error = exc
|
||||
raise ValueError(
|
||||
"敏感字段解密失败,请确认 APP_ENCRYPTION_KEY 是否正确"
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"""FastAPI 依赖注入"""
|
||||
|
||||
|
||||
from fastapi import Depends, HTTPException, Request, WebSocket, status
|
||||
from fastapi.security import OAuth2PasswordBearer
|
||||
from jose import JWTError
|
||||
|
||||
@@ -483,7 +483,7 @@ def _check_cookies(ids: str, db: Session, current: User, *, detailed: bool) -> d
|
||||
for future in as_completed(futures):
|
||||
try:
|
||||
results.append(future.result())
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
task = futures[future]
|
||||
results.append(
|
||||
{
|
||||
@@ -623,7 +623,7 @@ def _start_relogin_tasks(
|
||||
def run_relogin_batch():
|
||||
try:
|
||||
runner.run()
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
runner._push_log("error", f"批量重新登录异常: {exc}")
|
||||
message = f"重新登录异常: {exc}(旧 Cookie 已保留)"
|
||||
for task_id in task_ids:
|
||||
|
||||
@@ -852,12 +852,14 @@ def stop_auto_register_batch(
|
||||
)
|
||||
def retry_auto_register_batch(
|
||||
batch_id: str,
|
||||
req: HuyaAutoRegisterRetryRequest = HuyaAutoRegisterRetryRequest.model_construct(),
|
||||
req: HuyaAutoRegisterRetryRequest | None = None,
|
||||
db: Session = Depends(get_db),
|
||||
current: User = Depends(get_current_user),
|
||||
):
|
||||
"""继续批次:默认从停止处往下跑(跳过成功与已失败);可传 mode 改行为。"""
|
||||
_require_huya_perm(current, "huya:import")
|
||||
if req is None:
|
||||
req = HuyaAutoRegisterRetryRequest.model_construct()
|
||||
use_proxy = req.use_proxy
|
||||
# 先看历史批次是否用过代理
|
||||
snapshot = huya_register_registry.get_snapshot(batch_id)
|
||||
@@ -1075,7 +1077,7 @@ def password_login_selected_accounts(
|
||||
"account": _account_out(account, include_cookie=include_cookie),
|
||||
}
|
||||
)
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
account.status = "login_failed"
|
||||
account.updated_at = datetime.now(UTC)
|
||||
db.commit()
|
||||
@@ -1239,7 +1241,7 @@ def app_password_login_selected_accounts(
|
||||
"account": _account_out(account, include_cookie=include_cookie),
|
||||
}
|
||||
)
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
account.status = "login_failed"
|
||||
account.updated_at = datetime.now(UTC)
|
||||
db.commit()
|
||||
|
||||
@@ -58,9 +58,11 @@ async def create_batch(
|
||||
acc = db.query(Account).filter(Account.id == aid).first()
|
||||
if not acc:
|
||||
continue
|
||||
if not user_has_permission(current, "login:view_all"):
|
||||
if acc.assigned_to != current.id:
|
||||
continue
|
||||
if (
|
||||
not user_has_permission(current, "login:view_all")
|
||||
and acc.assigned_to != current.id
|
||||
):
|
||||
continue
|
||||
valid_ids.append(aid)
|
||||
|
||||
if not valid_ids:
|
||||
|
||||
@@ -33,7 +33,7 @@ def hash_password(password: str) -> str:
|
||||
def verify_password(plain: str, hashed: str) -> bool:
|
||||
try:
|
||||
return bcrypt.checkpw(plain.encode("utf-8")[:72], hashed.encode("utf-8"))
|
||||
except Exception:
|
||||
except Exception: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
return False
|
||||
|
||||
|
||||
|
||||
@@ -258,7 +258,7 @@ class AccountCheckRunner:
|
||||
stop_event=self._stop,
|
||||
api_strategy=WgapiLoginAPI(),
|
||||
).check_account()
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
self._set_item(
|
||||
index, status="error", message=f"检测异常: {exc}", finished_at=_now()
|
||||
)
|
||||
@@ -319,7 +319,7 @@ class AccountCheckRunner:
|
||||
with self._lock:
|
||||
items = list(self.batch.items)
|
||||
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
||||
timestamp = datetime.now(UTC).strftime("%Y%m%d_%H%M%S")
|
||||
buffer = io.BytesIO()
|
||||
with zipfile.ZipFile(buffer, "w", compression=zipfile.ZIP_DEFLATED) as zf:
|
||||
for status in EXPORT_STATUS_ORDER:
|
||||
@@ -367,7 +367,7 @@ class AccountCheckRunner:
|
||||
|
||||
for future in as_completed(futures):
|
||||
future.result()
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
self._set_batch(
|
||||
status="error", message=f"批次执行异常: {exc}", finished_at=_now()
|
||||
)
|
||||
|
||||
@@ -52,7 +52,7 @@ def check_douyu_cookie(cookie: str) -> dict:
|
||||
if isinstance(fish_data, dict)
|
||||
else "响应异常"
|
||||
)
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
fish_msg = f"请求失败: {exc}"
|
||||
|
||||
level_ok = False
|
||||
@@ -83,7 +83,7 @@ def check_douyu_cookie(cookie: str) -> dict:
|
||||
if isinstance(level_data, dict)
|
||||
else "响应异常"
|
||||
)
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
level_msg = f"请求失败: {exc}"
|
||||
|
||||
valid = fish_ok and level_ok
|
||||
|
||||
@@ -133,7 +133,7 @@ class DouyuBatchRunner(
|
||||
if "task" in locals() and task:
|
||||
self._mark_task(worker_db, task, "failed", str(exc))
|
||||
self._push_log("warning", f"斗鱼任务失败: {exc}")
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
if "task" in locals() and task:
|
||||
self._mark_task(worker_db, task, "error", str(exc))
|
||||
self._push_log("error", f"斗鱼任务异常: {exc}")
|
||||
@@ -177,7 +177,7 @@ class DouyuBatchRunner(
|
||||
for future in as_completed(futures):
|
||||
try:
|
||||
future.result()
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
self._push_log("error", f"Worker 异常: {exc}")
|
||||
|
||||
if self._stop.is_set():
|
||||
|
||||
@@ -386,9 +386,9 @@ class BindMixin:
|
||||
]
|
||||
if not bound:
|
||||
return None
|
||||
return sorted(
|
||||
return min(
|
||||
bound, key=lambda info: prefer.index(str(info.get("act_alias") or ""))
|
||||
)[0]
|
||||
)
|
||||
|
||||
def _pick_baseline_bind_info(
|
||||
self,
|
||||
|
||||
@@ -138,7 +138,7 @@ class DouyuBatchRunnerCore:
|
||||
if proxy_url:
|
||||
return {"http": proxy_url, "https": proxy_url}
|
||||
self._push_log("warning", "代理 API 未返回可用代理, 本任务降级直连")
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
self._push_log("warning", f"取代理失败, 本任务降级直连: {exc}")
|
||||
return None
|
||||
|
||||
@@ -193,7 +193,7 @@ class DouyuBatchRunnerCore:
|
||||
return
|
||||
try:
|
||||
payload = douyu_task_payload(task)
|
||||
except Exception:
|
||||
except Exception: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
logger.exception("[douyu] 推送任务状态失败: task_id={}", task.id)
|
||||
return
|
||||
event = {
|
||||
|
||||
@@ -136,7 +136,7 @@ class DonateMixin:
|
||||
)
|
||||
baseline_points = baseline["esports_points"]
|
||||
db.commit()
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
self._push_log("warning", f"赠送{gift_name}前刷新电竞积分失败: {exc}")
|
||||
|
||||
result = client.donate_esports_gift(
|
||||
@@ -158,7 +158,7 @@ class DonateMixin:
|
||||
refresh_errors = []
|
||||
try:
|
||||
result.update(self._refresh_account_gold_balance(client, account))
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
refresh_errors.append(f"鱼翅余额: {exc}")
|
||||
try:
|
||||
points_result = self._refresh_esports_handbook(
|
||||
@@ -171,7 +171,7 @@ class DonateMixin:
|
||||
and points_result["esports_points"] is not None
|
||||
and points_result["esports_points"] != baseline_points
|
||||
)
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
refresh_errors.append(f"电竞积分: {exc}")
|
||||
if refresh_errors:
|
||||
result["refresh_errors"] = refresh_errors
|
||||
@@ -240,7 +240,7 @@ class DonateMixin:
|
||||
)
|
||||
db.commit()
|
||||
baseline_points = baseline_result["points"]
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
self._push_log("warning", f"赠送精英令前刷新积分失败: {exc}")
|
||||
result = client.donate_elite_gift(
|
||||
gift_count=gift_count,
|
||||
@@ -252,7 +252,7 @@ class DonateMixin:
|
||||
refresh_errors = []
|
||||
try:
|
||||
result.update(self._refresh_account_gold_balance(client, account))
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
refresh_errors.append(f"鱼翅余额: {exc}")
|
||||
try:
|
||||
result.update(
|
||||
@@ -268,7 +268,7 @@ class DonateMixin:
|
||||
gift_count,
|
||||
)
|
||||
)
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
refresh_errors.append(f"积分: {exc}")
|
||||
if refresh_errors:
|
||||
result["refresh_errors"] = refresh_errors
|
||||
|
||||
@@ -106,7 +106,7 @@ class GoldMixin:
|
||||
f"鱼翅支付码已生成,等待到账(当前鱼翅 {last_gold if last_gold is not None else '-'})",
|
||||
result,
|
||||
)
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
poll_count += 1
|
||||
result["payment_poll_count"] = poll_count
|
||||
result["payment_poll_error"] = str(exc)
|
||||
@@ -260,7 +260,7 @@ class GoldMixin:
|
||||
baseline = self._refresh_account_gold_balance(client, account)
|
||||
baseline_gold = baseline["gold_balance"]
|
||||
db.commit()
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
self._push_log("warning", f"生成鱼翅码前刷新余额失败: {exc}")
|
||||
result = client.create_gold_qr(
|
||||
amount=amount, pay_type=int(config["gold_pay_type"])
|
||||
|
||||
@@ -202,7 +202,7 @@ class GoodsMixin:
|
||||
result.update(
|
||||
self._refresh_account_points(client, account, cookie, ctn=ctn)
|
||||
)
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
self._push_log("warning", f"支付锁单后刷新积分失败: {exc}")
|
||||
self._mark_task(
|
||||
db,
|
||||
@@ -493,7 +493,7 @@ class GoodsMixin:
|
||||
points_refresh = self._refresh_account_points(
|
||||
client, account, cookie, ctn=ctn
|
||||
)
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
self._push_log("warning", f"兑换后刷新积分失败: {exc}")
|
||||
self._mark_task(
|
||||
db,
|
||||
@@ -549,7 +549,7 @@ class GoodsMixin:
|
||||
)
|
||||
baseline_points = baseline["esports_points"]
|
||||
db.commit()
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
self._push_log("warning", f"兑换电竞皮肤前刷新积分失败: {exc}")
|
||||
|
||||
result = client.exchange_esports_goods(
|
||||
@@ -571,7 +571,7 @@ class GoodsMixin:
|
||||
)
|
||||
result.update(points_result)
|
||||
result["esports_points_after_exchange"] = points_result["esports_points"]
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
result["esports_points_refresh_error"] = str(exc)
|
||||
|
||||
account.esports_bind_status = "esports_goods_exchanged"
|
||||
|
||||
@@ -95,7 +95,7 @@ class ManualMixin:
|
||||
f"精英宝典支付码已生成,等待开通到账(当前积分 {last_points if last_points is not None else '-'})",
|
||||
result,
|
||||
)
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
poll_count += 1
|
||||
result["payment_poll_count"] = poll_count
|
||||
result["payment_poll_error"] = str(exc)
|
||||
@@ -184,7 +184,7 @@ class ManualMixin:
|
||||
f"积分 {last_manual_score if last_manual_score is not None else '-'})",
|
||||
result,
|
||||
)
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
poll_count += 1
|
||||
result["payment_poll_count"] = poll_count
|
||||
result["payment_poll_error"] = str(exc)
|
||||
@@ -276,7 +276,7 @@ class ManualMixin:
|
||||
baseline_manual_type = baseline_result["esports_manual_type"]
|
||||
baseline_manual_score = baseline_result["esports_manual_score"]
|
||||
db.commit()
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
self._push_log("warning", f"生成电竞手册支付码前查询活动状态失败: {exc}")
|
||||
|
||||
if baseline_manual_type is not None and baseline_manual_type >= 1:
|
||||
|
||||
@@ -135,7 +135,7 @@ class XpdMixin:
|
||||
result["before_role_name"] = str(before.get("role_name") or "")
|
||||
result["before_area_name"] = str(before.get("area_name") or "")
|
||||
result["before_plat_name"] = str(before.get("plat_name") or "")
|
||||
except Exception:
|
||||
except Exception: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
result["before_bound"] = False
|
||||
result["before_role_name"] = ""
|
||||
result["bind_polling"] = True
|
||||
@@ -208,7 +208,7 @@ class XpdMixin:
|
||||
f"等待扫码绑定(第 {poll_count} 次)",
|
||||
result,
|
||||
)
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
poll_count += 1
|
||||
result["bind_poll_count"] = poll_count
|
||||
result["bind_poll_error"] = str(exc)
|
||||
@@ -259,7 +259,7 @@ class XpdMixin:
|
||||
else:
|
||||
account.xpd_game_name = role_name
|
||||
account.updated_at = datetime.now(UTC)
|
||||
except Exception:
|
||||
except Exception: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
account.xpd_game_name = role_name
|
||||
account.updated_at = datetime.now(UTC)
|
||||
account.xpd_bind_status = "xpd_bound"
|
||||
@@ -409,8 +409,8 @@ class XpdMixin:
|
||||
plat = str(role_plat) if role_plat not in (None, "") else plat
|
||||
areaid = str(role_area) or areaid
|
||||
self._apply_xpd_role_to_account(account, role, role_area)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as exc: # noqa: BLE001
|
||||
self._push_log("debug", f"小店角色信息补全失败: {exc}")
|
||||
if not openid or not roleid:
|
||||
self._mark_task(
|
||||
db, task, "failed", "未获取到小店绑定角色,请先生成二维码扫码绑定"
|
||||
|
||||
@@ -690,7 +690,7 @@ class HuyaRegisterRunner:
|
||||
)
|
||||
try:
|
||||
account_id, username, uid = self._save_success(index, result)
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
status = "error"
|
||||
cookie = ""
|
||||
full_cookie = ""
|
||||
@@ -779,7 +779,7 @@ class HuyaRegisterRunner:
|
||||
|
||||
for future in as_completed(futures):
|
||||
future.result()
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
with self._lock:
|
||||
self.batch.status = "error"
|
||||
self.batch.message = f"批次执行异常: {exc}"
|
||||
|
||||
@@ -118,7 +118,7 @@ class HuyaBatchRunner(
|
||||
self._push_log("success", f"[{current}] {name} {task.message}")
|
||||
else:
|
||||
self._push_log("error", f"[{current}] {name} {task.message}")
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
self._mark_task(worker_db, task, "error", f"执行异常: {exc}")
|
||||
self._push_log("error", f"[{current}] {name} 执行异常: {exc}")
|
||||
finally:
|
||||
@@ -196,12 +196,12 @@ class HuyaBatchRunner(
|
||||
for future in as_completed(futures):
|
||||
try:
|
||||
future.result()
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
self._push_log("error", f"虎牙 Worker 异常: {exc}")
|
||||
|
||||
self._push_log("info", f"虎牙批次 {self.batch_id} 完成")
|
||||
self._push_log("result", "")
|
||||
except Exception as exc:
|
||||
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
self._push_log("error", f"虎牙批次执行异常: {exc}")
|
||||
self._push_log("result", "")
|
||||
finally:
|
||||
|
||||
@@ -90,7 +90,7 @@ class HuyaBatchRunnerCore:
|
||||
def _format_local_time(timestamp: int) -> str:
|
||||
if not timestamp:
|
||||
return ""
|
||||
return datetime.fromtimestamp(timestamp).strftime("%Y-%m-%d %H:%M:%S")
|
||||
return datetime.fromtimestamp(timestamp, UTC).strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
@staticmethod
|
||||
def _parse_scheduled_time(value) -> datetime | None:
|
||||
|
||||
@@ -267,10 +267,13 @@ class GoodsMixin:
|
||||
if self.payload.get("scheduled_at") and scheduled_at is None:
|
||||
self._mark_task(worker_db, task, "failed", "定时兑换时间格式无效")
|
||||
return
|
||||
if scheduled_at and scheduled_at.timestamp() > time.time():
|
||||
if not self._wait_until(scheduled_at, uid):
|
||||
self._mark_task(worker_db, task, "stopped", "兑换任务已停止")
|
||||
return
|
||||
if (
|
||||
scheduled_at
|
||||
and scheduled_at.timestamp() > time.time()
|
||||
and not self._wait_until(scheduled_at, uid)
|
||||
):
|
||||
self._mark_task(worker_db, task, "stopped", "兑换任务已停止")
|
||||
return
|
||||
|
||||
client: Any = HuyaHttpClient(
|
||||
logger=lambda msg: self._push_log("info", f"[{uid}] {msg}")
|
||||
|
||||
@@ -348,9 +348,8 @@ def cleanup_orphan_huya_tasks(
|
||||
query = db.query(HuyaTask).filter(HuyaTask.status.in_(statuses))
|
||||
if batch_id:
|
||||
query = query.filter(HuyaTask.batch_id == batch_id)
|
||||
elif active_batch_ids is not None:
|
||||
if active_batch_ids:
|
||||
query = query.filter(~HuyaTask.batch_id.in_(list(active_batch_ids)))
|
||||
elif active_batch_ids is not None and active_batch_ids:
|
||||
query = query.filter(~HuyaTask.batch_id.in_(list(active_batch_ids)))
|
||||
# active_batch_ids is None 且未指定 batch_id:清理全部匹配状态
|
||||
|
||||
tasks = query.all()
|
||||
|
||||
@@ -372,7 +372,7 @@ class LoginBatchRunner:
|
||||
f"[{current}] {acc_info['username']} {action_name}失败: {result.message}",
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
except Exception as e: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
if self.mode == "relogin":
|
||||
task.status = "relogin_failed"
|
||||
task.message = f"重新登录异常: {e}(旧 Cookie 已保留)"
|
||||
@@ -462,10 +462,12 @@ class LoginBatchRunner:
|
||||
if not acc:
|
||||
self._push_log("warning", f"跳过无账号的任务 #{task_id}")
|
||||
continue
|
||||
if "login:view_all" not in self.creator_permissions:
|
||||
if acc.assigned_to != self.created_by:
|
||||
self._push_log("warning", f"跳过无权账号: {acc.username}")
|
||||
continue
|
||||
if (
|
||||
"login:view_all" not in self.creator_permissions
|
||||
and acc.assigned_to != self.created_by
|
||||
):
|
||||
self._push_log("warning", f"跳过无权账号: {acc.username}")
|
||||
continue
|
||||
_append_task_info(task, acc)
|
||||
else:
|
||||
seen_account_ids = set()
|
||||
@@ -482,10 +484,12 @@ class LoginBatchRunner:
|
||||
if not acc:
|
||||
continue
|
||||
# 权限检查:客服只能跑分配给自己的
|
||||
if "login:view_all" not in self.creator_permissions:
|
||||
if acc.assigned_to != self.created_by:
|
||||
self._push_log("warning", f"跳过无权账号: {acc.username}")
|
||||
continue
|
||||
if (
|
||||
"login:view_all" not in self.creator_permissions
|
||||
and acc.assigned_to != self.created_by
|
||||
):
|
||||
self._push_log("warning", f"跳过无权账号: {acc.username}")
|
||||
continue
|
||||
|
||||
# 一个斗鱼账号只保留一条成功 CK:再次普通登录时更新最新成功记录。
|
||||
latest_success_task = (
|
||||
@@ -563,7 +567,7 @@ class LoginBatchRunner:
|
||||
for future in as_completed(futures):
|
||||
try:
|
||||
future.result()
|
||||
except Exception as e:
|
||||
except Exception as e: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
self._push_log("error", f"Worker 异常: {e}")
|
||||
|
||||
self._push_log("info", f"批量{action_name}任务 {batch_id} 完成")
|
||||
|
||||
@@ -189,7 +189,7 @@ class ProxyService:
|
||||
|
||||
push("error", "未配置代理地址或API")
|
||||
push("result", "")
|
||||
except Exception as e:
|
||||
except Exception as e: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
push("error", f"测试异常: {e}")
|
||||
push("result", "")
|
||||
|
||||
@@ -254,7 +254,7 @@ class ProxyService:
|
||||
if whitelist_ip:
|
||||
local_ip = whitelist_ip
|
||||
push("info", f"从代理API获取到本机IP: {local_ip}")
|
||||
except Exception as e:
|
||||
except Exception as e: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
push("warning", f"代理API请求失败: {e}")
|
||||
|
||||
if not local_ip:
|
||||
@@ -293,7 +293,7 @@ class ProxyService:
|
||||
push("success" if sync_ok else "error", f"白名单同步: {sync_msg}")
|
||||
|
||||
push("result", "")
|
||||
except Exception as e:
|
||||
except Exception as e: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
push("error", f"测试异常: {e}")
|
||||
push("result", "")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user