This commit is contained in:
2026-03-08 03:19:16 +08:00
parent 6775bbcc62
commit 942c6f93d7
+7 -4
View File
@@ -57,6 +57,9 @@ class GeometryVerificationService:
import tempfile
import os
# 确保 stp_path 是字符串
stp_path_str = str(stp_path)
# 创建临时输出文件
with tempfile.NamedTemporaryFile(mode='w', suffix='.json', delete=False) as f:
output_path = f.name
@@ -70,7 +73,7 @@ class GeometryVerificationService:
try:
result = subprocess.run(['which', cmd_name], capture_output=True, text=True)
if result.returncode == 0 and result.stdout.strip():
cmd = [cmd_name, str(self.verification_script), stp_path]
cmd = [cmd_name, str(self.verification_script), stp_path_str]
logger.debug(f"找到 FreeCAD 命令: {cmd_name}")
break
except:
@@ -84,7 +87,7 @@ class GeometryVerificationService:
cmd = [
'env', 'QT_QPA_PLATFORM=offscreen',
'freecad', '-c',
str(self.verification_script), stp_path
str(self.verification_script), stp_path_str
]
except:
pass
@@ -94,7 +97,7 @@ class GeometryVerificationService:
try:
result = subprocess.run(['which', 'xvfb-run'], capture_output=True, text=True)
if result.returncode == 0:
cmd = ['xvfb-run', 'freecad', '-c', str(self.verification_script), stp_path]
cmd = ['xvfb-run', 'freecad', '-c', str(self.verification_script), stp_path_str]
except:
pass
@@ -120,7 +123,7 @@ class GeometryVerificationService:
if process.returncode == 0:
# 尝试读取生成的报告文件
report_path = Path(stp_path).stem + "_verification_report.json"
report_path = Path(stp_path_str).stem + "_verification_report.json"
if Path(report_path).exists():
with open(report_path, 'r', encoding='utf-8') as f:
result = json.load(f)