diff --git a/backend/app/workers/pipeline.py b/backend/app/workers/pipeline.py index 07a2462..896a03a 100644 --- a/backend/app/workers/pipeline.py +++ b/backend/app/workers/pipeline.py @@ -182,7 +182,8 @@ async def translate_article(article_id: int) -> None: translated_chunks.append(tr.text) tr_body = "\n\n".join(translated_chunks) - engine_label = "tencent" + # 用 service 返回的 engine 标签(spark / tencent / tencent_maas / agnes / nllb / cache) + engine_label = tr_title.engine or "tencent" status = "ok" if (tr_title.text and tr_body) else "partial" except Exception as e: logger.exception("translate article %s failed: %s", article_id, e) diff --git a/scripts/deploy_pull.py b/scripts/deploy_pull.py index 5c02a02..3fc9247 100644 --- a/scripts/deploy_pull.py +++ b/scripts/deploy_pull.py @@ -24,6 +24,13 @@ import subprocess import sys from pathlib import Path +# 在 Windows GBK 终端下也能正常输出中文/Unicode +try: + sys.stdout.reconfigure(encoding="utf-8") + sys.stderr.reconfigure(encoding="utf-8") +except Exception: + pass + import paramiko # ===== 默认配置(适配当前项目)===== @@ -92,7 +99,7 @@ def deploy( print(f"=== 连接 {user}@{host}:{port} ===") c = _connect(host, port, user, ssh_key) - print(f"✓ 已免密登录") + print(f"[OK] 已免密登录") try: # 1) 手动回退 @@ -100,9 +107,9 @@ def deploy( print(f"\n=== 手动回退到 {rollback[:12]} ===") rc, out, err = _run(c, f"cd {repo_dir} && git reset --hard {rollback}", timeout=30) if rc != 0: - print(f"✗ 回退失败: {err}") + print(f"[FAIL] 回退失败: {err}") return 1 - print("✓ 已回退") + print("[OK] 已回退") rc, head, _ = _run(c, f"cd {repo_dir} && git rev-parse HEAD", timeout=10) print(f"现在 HEAD: {head.strip()[:12]}") return 0 @@ -135,7 +142,7 @@ def deploy( rc, out, err = _run(c, cmd, timeout=180) if rc != 0: - print(f"✗ {action} 失败 (rc={rc})") + print(f"[FAIL] {action} 失败 (rc={rc})") if out.strip(): print(f"stdout:\n{out}") if err.strip(): print(f"stderr:\n{err}") # 回滚(只在 pull 时) @@ -143,12 +150,12 @@ def deploy( print(f"\n=== 回退到 {before_sha[:12]} ===") rrc, _, rerr = _run(c, f"cd {repo_dir} && git reset --hard {before_sha}", timeout=30) if rrc == 0: - print(f"✓ 已回退到 {before_sha[:12]}") + print(f"[OK] 已回退到 {before_sha[:12]}") else: - print(f"✗ 回退失败: {rerr}") + print(f"[FAIL] 回退失败: {rerr}") return 1 - print(f"✓ {action} 成功") + print(f"[OK] {action} 成功") if out.strip(): print(out) # 5) 拉后状态 @@ -162,9 +169,9 @@ def deploy( rc, status, _ = _run(c, f"cd {repo_dir} && git status --porcelain", timeout=10) if status.strip(): - print(f"⚠️ working tree 不干净:\n{status}") + print(f"[WARN]️ working tree 不干净:\n{status}") else: - print("✓ working tree 干净") + print("[OK] working tree 干净") # 6) 跟本地 main 对比 local = _local_head() @@ -172,9 +179,9 @@ def deploy( print(f"本地 HEAD: {local[:12]}") print(f"服务器 HEAD: {head_sha[:12]}") if local.startswith(head_sha): - print("✓ 服务器 == 本地") + print("[OK] 服务器 == 本地") else: - print("ℹ️ 服务器跟本地不完全一致(可能本地未推送,或服务器在另一条 commit 上)") + print("[INFO]️ 服务器跟本地不完全一致(可能本地未推送,或服务器在另一条 commit 上)") # 7) 总结 print(f"\n=== 部署报告 ===")