-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomplete_robot_log_analyzer.py
More file actions
36 lines (32 loc) · 1.35 KB
/
Copy pathcomplete_robot_log_analyzer.py
File metadata and controls
36 lines (32 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
import json
from config import LOG_DIRECTORY, TEMP_REPORTS_DIRECTORY, REPORTS_DIRECTORY
class CompleteRobotLogAnalyzer:
def __init__(self, log_directory=None):
self.log_directory = log_directory or LOG_DIRECTORY
def generate_integrated_report(self):
# 简单假数据,后续再替换为真分析
return {
"summary": "Mock analysis summary",
"log_directory": self.log_directory,
"task_count": 0,
"error_count": 0
}
def save_reports(self, temp_output_dir=None):
temp_output_dir = temp_output_dir or TEMP_REPORTS_DIRECTORY
os.makedirs(temp_output_dir, exist_ok=True)
os.makedirs(REPORTS_DIRECTORY, exist_ok=True)
report_data = self.generate_integrated_report()
report_id = "report_mock_1"
json_path = os.path.join(temp_output_dir, f"{report_id}.json")
with open(json_path, "w", encoding="utf-8") as f:
json.dump(report_data, f, ensure_ascii=False, indent=2)
# 同时在 reports/ 写入一个简单 txt
txt_path = os.path.join(REPORTS_DIRECTORY, f"{report_id}.txt")
with open(txt_path, "w", encoding="utf-8") as f:
f.write("Mock report\n")
return {
"report_id": report_id,
"json_path": json_path,
"txt_path": txt_path
}