x
This commit is contained in:
@@ -57,6 +57,9 @@ class GeometryVerificationService:
|
|||||||
import tempfile
|
import tempfile
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
# 确保 stp_path 是字符串
|
||||||
|
stp_path_str = str(stp_path)
|
||||||
|
|
||||||
# 创建临时输出文件
|
# 创建临时输出文件
|
||||||
with tempfile.NamedTemporaryFile(mode='w', suffix='.json', delete=False) as f:
|
with tempfile.NamedTemporaryFile(mode='w', suffix='.json', delete=False) as f:
|
||||||
output_path = f.name
|
output_path = f.name
|
||||||
@@ -70,7 +73,7 @@ class GeometryVerificationService:
|
|||||||
try:
|
try:
|
||||||
result = subprocess.run(['which', cmd_name], capture_output=True, text=True)
|
result = subprocess.run(['which', cmd_name], capture_output=True, text=True)
|
||||||
if result.returncode == 0 and result.stdout.strip():
|
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}")
|
logger.debug(f"找到 FreeCAD 命令: {cmd_name}")
|
||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
@@ -84,7 +87,7 @@ class GeometryVerificationService:
|
|||||||
cmd = [
|
cmd = [
|
||||||
'env', 'QT_QPA_PLATFORM=offscreen',
|
'env', 'QT_QPA_PLATFORM=offscreen',
|
||||||
'freecad', '-c',
|
'freecad', '-c',
|
||||||
str(self.verification_script), stp_path
|
str(self.verification_script), stp_path_str
|
||||||
]
|
]
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
@@ -94,7 +97,7 @@ class GeometryVerificationService:
|
|||||||
try:
|
try:
|
||||||
result = subprocess.run(['which', 'xvfb-run'], capture_output=True, text=True)
|
result = subprocess.run(['which', 'xvfb-run'], capture_output=True, text=True)
|
||||||
if result.returncode == 0:
|
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:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -120,7 +123,7 @@ class GeometryVerificationService:
|
|||||||
|
|
||||||
if process.returncode == 0:
|
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():
|
if Path(report_path).exists():
|
||||||
with open(report_path, 'r', encoding='utf-8') as f:
|
with open(report_path, 'r', encoding='utf-8') as f:
|
||||||
result = json.load(f)
|
result = json.load(f)
|
||||||
|
|||||||
Reference in New Issue
Block a user