fix(translate): pipeline 写库用 service 返回的 engine(之前写死 tencent)
pipeline.translate_article 调 translation_service.translate() 后, 自己写 engine_label='tencent',忽略 service 实际返回的 engine。 效果:即使 service 内部按 spark 优先链路跑成功了, DB 里 translation_engine 也只显示 tencent。 修法: 改用 tr_title.engine(or 默认 tencent 兜底)。 附带: deploy_pull.py 加 sys.stdout.reconfigure(encoding='utf-8'), Windows GBK 终端下 Unicode 字符不会再 UnicodeEncodeError。
This commit is contained in:
@@ -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=== 部署报告 ===")
|
||||
|
||||
Reference in New Issue
Block a user