This commit is contained in:
2026-03-08 22:27:53 +08:00
parent 5712abb745
commit 41f6498291
+20 -2
View File
@@ -76,21 +76,39 @@ class GeometryVerificationService:
cmd = None
# 使用 shutil.which 查找 FreeCAD 命令(更快)
for cmd_name in ['freecad', 'freecadcmd', 'freecad-cmd']:
for cmd_name in ['freecad', 'freecadcmd', 'freecad-daily']:
cmd_path = shutil.which(cmd_name)
if cmd_path:
cmd = [cmd_path, str(self.verification_script), str(Path(stp_path_str).absolute())]
logger.info(f"找到 FreeCAD 命令: {cmd_path}")
break
# 检查 Flatpak 版本
if not cmd and shutil.which('flatpak'):
try:
result = subprocess.run(['flatpak', 'list', '--app'], capture_output=True, text=True)
if 'org.freecad.FreeCAD' in result.stdout:
cmd = ['flatpak', 'run', 'org.freecad.FreeCAD', str(self.verification_script), str(Path(stp_path_str).absolute())]
logger.info("找到 FreeCAD Flatpak 版本")
except:
pass
# 如果 which 找不到,尝试直接检查常见路径
if not cmd:
for cmd_path in ['/usr/local/bin/freecad', '/usr/bin/freecad', '/usr/local/bin/freecadcmd', '/usr/bin/freecadcmd', '/snap/bin/freecad.cmd']:
for cmd_path in ['/usr/local/bin/freecad', '/usr/bin/freecad', '/usr/bin/freecad-daily', '/usr/local/bin/freecadcmd', '/usr/bin/freecadcmd', '/snap/bin/freecad.cmd']:
if Path(cmd_path).exists():
cmd = [cmd_path, str(self.verification_script), str(Path(stp_path_str).absolute())]
logger.info(f"找到 FreeCAD 命令路径: {cmd_path}")
break
# 尝试使用 xvfb-run 运行 AppImage
if not cmd and shutil.which('xvfb-run'):
for appimage_path in ['/usr/local/bin/freecad', '/opt/freecad.AppImage']:
if Path(appimage_path).exists():
cmd = ['xvfb-run', appimage_path, str(self.verification_script), str(Path(stp_path_str).absolute())]
logger.info(f"使用 xvfb-run 运行: {appimage_path}")
break
if not cmd:
logger.warning("FreeCAD 命令行工具不可用,跳过验证")
return {