From 942c6f93d7acff17d77c7974f79604d7646dfa90 Mon Sep 17 00:00:00 2001 From: SZCJW <792430652@qq.com> Date: Sun, 8 Mar 2026 03:19:16 +0800 Subject: [PATCH] x --- src/services/verification_service.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/services/verification_service.py b/src/services/verification_service.py index 4fb437f..42afc42 100644 --- a/src/services/verification_service.py +++ b/src/services/verification_service.py @@ -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)