显示处理进度状态
(output_dir: str)
| 22 | sys.exit(1) |
| 23 | |
| 24 | def show_progress_status(output_dir: str): |
| 25 | """显示处理进度状态""" |
| 26 | progress_file = os.path.join(output_dir, "progress.json") |
| 27 | |
| 28 | if not os.path.exists(progress_file): |
| 29 | print("📋 未找到进度文件,没有正在进行的任务") |
| 30 | return |
| 31 | |
| 32 | try: |
| 33 | with open(progress_file, 'r', encoding='utf-8') as f: |
| 34 | progress_data = json.load(f) |
| 35 | |
| 36 | print("处理进度状态:") |
| 37 | print(f"总文件: {progress_data.get('total_files', 'N/A')}, 已处理: {progress_data.get('processed_count', 0)}") |
| 38 | |
| 39 | status = progress_data.get('current_file', 'N/A') |
| 40 | if status == 'COMPLETED': |
| 41 | print("状态: 已完成") |
| 42 | elif status == 'INTERRUPTED': |
| 43 | print("状态: 被中断") |
| 44 | else: |
| 45 | print("状态: 进行中") |
| 46 | |
| 47 | # 检查批次文件 |
| 48 | batch_dirs = [d for d in os.listdir(output_dir) |
| 49 | if d.startswith("batch_") and os.path.isdir(os.path.join(output_dir, d))] |
| 50 | |
| 51 | if batch_dirs: |
| 52 | print(f"已保存批次: {len(batch_dirs)} 个") |
| 53 | |
| 54 | except Exception as e: |
| 55 | print(f"❌ 读取进度文件失败: {str(e)}") |
| 56 | |
| 57 | def clean_progress(output_dir: str): |
| 58 | """清理进度文件,重新开始处理""" |