This commit is contained in:
beabigegg
2025-09-02 13:11:48 +08:00
parent a60d965317
commit b11a8272c4
76 changed files with 15321 additions and 200 deletions

42
simple_job_check.py Normal file
View File

@@ -0,0 +1,42 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
簡單檢查任務
"""
import sys
import os
# 添加 app 路徑
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
def main():
from app import create_app
from app.models.job import TranslationJob
from app.services.translation_service import TranslationService
app = create_app()
with app.app_context():
# 查詢等待中的任務
pending_jobs = TranslationJob.query.filter_by(status='PENDING').all()
print(f"等待中的任務數量: {len(pending_jobs)}")
if pending_jobs:
job = pending_jobs[0] # 處理第一個任務
try:
print(f"開始處理任務: {job.job_uuid}")
service = TranslationService()
result = service.translate_document(job.job_uuid)
print(f"處理完成: success={result.get('success', False)}")
if result.get('success'):
print(f"翻譯檔案: {len(result.get('output_files', []))}")
print(f"總成本: ${result.get('total_cost', 0)}")
except Exception as e:
print(f"處理失敗: {str(e)}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
main()