From 41f6498291b29cd316862b5a418e9c5803757817 Mon Sep 17 00:00:00 2001 From: SZCJW <792430652@qq.com> Date: Sun, 8 Mar 2026 22:27:53 +0800 Subject: [PATCH] x --- src/services/verification_service.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/services/verification_service.py b/src/services/verification_service.py index 0e5c0ac..b76fc70 100644 --- a/src/services/verification_service.py +++ b/src/services/verification_service.py @@ -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 {