py3: some diff for fem with py3
This commit is contained in:
@@ -28,6 +28,7 @@ __url__ = "http://www.freecadweb.org"
|
||||
## \addtogroup FEM
|
||||
# @{
|
||||
|
||||
import sys
|
||||
import FreeCAD
|
||||
import FemTools
|
||||
from PySide import QtCore
|
||||
@@ -121,7 +122,10 @@ class FemToolsCcx(FemTools.FemTools):
|
||||
import subprocess
|
||||
p1 = subprocess.Popen(['which', 'ccx'], stdout=subprocess.PIPE)
|
||||
if p1.wait() == 0:
|
||||
ccx_path = p1.stdout.read().split('\n')[0]
|
||||
if sys.version_info.major >= 3:
|
||||
ccx_path = str(p1.stdout.read()).split('\n')[0]
|
||||
else:
|
||||
ccx_path = p1.stdout.read().split('\n')[0]
|
||||
elif p1.wait() == 1:
|
||||
error_message = "FEM: CalculiX binary ccx not found in standard system binary path. Please install ccx or set path to binary in FEM preferences tab CalculiX.\n"
|
||||
if FreeCAD.GuiUp:
|
||||
@@ -153,20 +157,20 @@ class FemToolsCcx(FemTools.FemTools):
|
||||
stderr=subprocess.PIPE, shell=False,
|
||||
startupinfo=startup_info)
|
||||
ccx_stdout, ccx_stderr = p.communicate()
|
||||
if ccx_binary_sig in ccx_stdout:
|
||||
if ccx_binary_sig in str(ccx_stdout):
|
||||
self.ccx_binary_present = True
|
||||
else:
|
||||
raise Exception("FEM: wrong ccx binary") # since we raise an exception the try will fail and the exception later with the error popup will be raised
|
||||
# TODO: I'm still able to break it. If user gives not a file but a path without a file or a file which is not a binary no excetion at all is raised.
|
||||
except OSError as e:
|
||||
FreeCAD.Console.PrintError(e.message)
|
||||
FreeCAD.Console.PrintError(str(e))
|
||||
if e.errno == 2:
|
||||
error_message = "FEM: CalculiX binary ccx \'{}\' not found. Please set the CalculiX binary ccx path in FEM preferences tab CalculiX.\n".format(ccx_binary)
|
||||
if FreeCAD.GuiUp:
|
||||
QtGui.QMessageBox.critical(None, error_title, error_message)
|
||||
raise Exception(error_message)
|
||||
except Exception as e:
|
||||
FreeCAD.Console.PrintError(e.message)
|
||||
FreeCAD.Console.PrintError(str(e))
|
||||
error_message = "FEM: CalculiX ccx \'{}\' output \'{}\' doesn't contain expected phrase \'{}\'. Please use ccx 2.6 or newer\n".format(ccx_binary, ccx_stdout, ccx_binary_sig)
|
||||
if FreeCAD.GuiUp:
|
||||
QtGui.QMessageBox.critical(None, error_title, error_message)
|
||||
|
||||
@@ -27,12 +27,16 @@ __url__ = "http://www.freecadweb.org"
|
||||
## @package TaskPanelFemMaterial
|
||||
# \ingroup FEM
|
||||
|
||||
import sys
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
from FreeCAD import Units
|
||||
from PySide import QtCore, QtGui
|
||||
from PySide.QtGui import QFileDialog, QMessageBox
|
||||
|
||||
if sys.version_info.major >= 3:
|
||||
unicode = str
|
||||
|
||||
|
||||
class _TaskPanelFemMaterial:
|
||||
'''The editmode TaskPanel for FemMaterial objects'''
|
||||
|
||||
@@ -30,6 +30,7 @@ __url__ = "http://www.freecadweb.org"
|
||||
import FemToolsCcx
|
||||
import FreeCAD
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import FreeCADGui
|
||||
import FemGui
|
||||
@@ -38,6 +39,9 @@ from PySide.QtCore import Qt
|
||||
from PySide.QtGui import QApplication
|
||||
|
||||
|
||||
if sys.version_info.major >= 3:
|
||||
unicode = str
|
||||
|
||||
class _TaskPanelFemSolverCalculix:
|
||||
def __init__(self, solver_object):
|
||||
self.form = FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Fem/PyGui/TaskPanelFemSolverCalculix.ui")
|
||||
|
||||
@@ -51,8 +51,12 @@ Version:
|
||||
|
||||
def importFCMat(fileName):
|
||||
"Read a FCMat file into a dictionary"
|
||||
import ConfigParser
|
||||
Config = ConfigParser.ConfigParser()
|
||||
try:
|
||||
import ConfigParser as configparser
|
||||
except ImportError:
|
||||
import configparser
|
||||
|
||||
Config = configparser.ConfigParser()
|
||||
Config.optionxform = str
|
||||
Config.read(fileName)
|
||||
dict1 = {}
|
||||
@@ -66,9 +70,12 @@ def importFCMat(fileName):
|
||||
|
||||
def exportFCMat(fileName,matDict):
|
||||
"Write a material dictionary to a FCMat file"
|
||||
import ConfigParser
|
||||
try:
|
||||
import ConfigParser as configparser
|
||||
except ImportError:
|
||||
import configparser
|
||||
import string
|
||||
Config = ConfigParser.ConfigParser()
|
||||
Config = configparser.ConfigParser()
|
||||
|
||||
# create groups
|
||||
for x in matDict.keys():
|
||||
|
||||
Reference in New Issue
Block a user