FEM: Make sure it's clear what failed when ccx is not set and cannot be found

Signed-off-by: Przemo Firszt <przemo@firszt.eu>
This commit is contained in:
Przemo Firszt 2015-10-18 20:43:44 +01:00 committed by wmayer
parent d8488027d7
commit d5cf69b646
2 changed files with 13 additions and 3 deletions

View File

@ -246,6 +246,8 @@ class FemTools(QtCore.QRunnable, QtCore.QObject):
import multiprocessing
import os
import subprocess
self.ccx_stdout = ""
self.ccx_stderr = ""
if self.inp_file_name != "" and self.ccx_binary_present:
ont_backup = os.environ.get('OMP_NUM_THREADS')
if not ont_backup:
@ -342,8 +344,13 @@ class FemTools(QtCore.QRunnable, QtCore.QObject):
ccx_stdout, ccx_stderr = p.communicate()
if ccx_binary_sig in ccx_stdout:
self.ccx_binary_present = True
except:
raise Exception("FEM: CalculiX ccx {} output {} doesn't contain expected phrase \'{}\'. Please use ccx 2.6 or newer".
except OSError, e:
FreeCAD.Console.PrintError(e.message)
if e.errno == 2:
raise Exception("FEM: CalculiX binary ccx \'{}\' not found. Please set it in FEM preferences.".format(ccx_binary))
except Exception as e:
FreeCAD.Console.PrintError(e.message)
raise Exception("FEM: CalculiX ccx \'{}\' output \'{}\' doesn't contain expected phrase \'{}\'. Please use ccx 2.6 or newer".
format(ccx_binary, ccx_stdout, ccx_binary_sig))
## Load results of ccx calculations from .frd file.

View File

@ -52,7 +52,10 @@ class FemWorkbench (Workbench):
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)
if ccx_path:
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem").SetString("ccxBinaryPath", ccx_path)
else:
FreeCAD.Console.PrintError("CalculiX ccx binary not found! Please set it manually in FEM preferences.\n")
except Exception as e:
FreeCAD.Console.PrintError(e.message)