From 0c1fb8e4d8fd010025217ac0fd3365d75b646a3e Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 14 Apr 2015 16:33:44 +0200 Subject: [PATCH] + delay checking for ccx path, handle exceptions --- src/Mod/Fem/InitGui.py | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/Mod/Fem/InitGui.py b/src/Mod/Fem/InitGui.py index 42a45d5820..50da9da6e3 100755 --- a/src/Mod/Fem/InitGui.py +++ b/src/Mod/Fem/InitGui.py @@ -33,27 +33,30 @@ class FemWorkbench (Workbench): "Fem workbench object" def __init__(self): - import subprocess - from platform import system self.__class__.Icon = FreeCAD.getResourceDir() + "Mod/Fem/Resources/icons/preferences-fem.svg" self.__class__.MenuText = "FEM" self.__class__.ToolTip = "FEM workbench" - ccx_path = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem").GetString("ccxBinaryPath") - if not ccx_path: - if system() == 'Linux': - p1 = subprocess.Popen(['which', 'ccx'], stdout=subprocess.PIPE) - if p1.wait() == 0: - ccx_path = p1.stdout.read().split('\n')[0] - elif system() == 'Windows': - ccx_path = FreeCAD.getHomePath() + 'bin/ccx.exe' - FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem").SetString("ccxBinaryPath", ccx_path) def Initialize(self): - # load the module - import Fem - import FemGui + # load the module + import Fem + import FemGui + import subprocess + from platform import system + ccx_path = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem").GetString("ccxBinaryPath") + if not ccx_path: + try: + if system() == 'Linux': + p1 = subprocess.Popen(['which', 'ccx'], stdout=subprocess.PIPE) + if p1.wait() == 0: + ccx_path = p1.stdout.read().split('\n')[0] + elif system() == 'Windows': + ccx_path = FreeCAD.getHomePath() + 'bin/ccx.exe' + FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem").SetString("ccxBinaryPath", ccx_path) + except Exception as e: + FreeCAD.Console.PrintError(e.message) def GetClassName(self): - return "FemGui::Workbench" + return "FemGui::Workbench" Gui.addWorkbench(FemWorkbench())