42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
#!/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() |