add method to get ccx version and inform user in case of problems

This commit is contained in:
wmayer
2017-08-02 23:59:41 +02:00
parent 71cfaa9967
commit 69dfcd2ae6
2 changed files with 24 additions and 0 deletions

View File

@@ -202,6 +202,25 @@ class FemToolsCcx(FemTools.FemTools):
return p.returncode
return -1
def get_ccx_version(self):
import re
import subprocess
from platform import system
startup_info = None
if system() == "Windows":
# Windows workaround to avoid blinking terminal window
startup_info = subprocess.STARTUPINFO()
startup_info.dwFlags = subprocess.STARTF_USESHOWWINDOW
ccx_stdout = None
ccx_stderr = None
# Now extract the version number
p = subprocess.Popen([self.ccx_binary, '-v'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE, shell=False,
startupinfo=startup_info)
ccx_stdout, ccx_stderr = p.communicate()
m = re.search(r"(\d+).(\d+)", ccx_stdout)
return (int(m.group(1)), int(m.group(2)))
def run(self):
ret_code = 0
message = self.check_prerequisites()

View File

@@ -169,6 +169,11 @@ class _TaskPanelFemSolverCalculix:
fea.load_results()
except:
QApplication.restoreOverrideCursor()
majorVersion, minorVersion = fea.get_ccx_version()
if majorVersion == 2 and minorVersion <= 10:
message = "The used CalculiX version {}.{} creates broken output files.\n" \
"Please upgrade to a newer version.".format(majorVersion, minorVersion)
QtGui.QMessageBox.warning(None, "Upgrade CalculiX", message)
raise
else:
QApplication.restoreOverrideCursor()