[FEM] remove unneeded checks for Python 3
since we only support Python >=3, these checks can go
This commit is contained in:
@@ -48,9 +48,8 @@ import FreeCAD
|
||||
from femtools.migrate_app import FemMigrateApp
|
||||
|
||||
|
||||
if sys.version_info.major >= 3:
|
||||
# migrate old FEM App objects
|
||||
sys.meta_path.append(FemMigrateApp())
|
||||
# migrate old FEM App objects
|
||||
sys.meta_path.append(FemMigrateApp())
|
||||
|
||||
|
||||
# add FEM App unit tests
|
||||
|
||||
@@ -50,9 +50,8 @@ from FreeCADGui import Workbench
|
||||
from femguiutils.migrate_gui import FemMigrateGui
|
||||
|
||||
|
||||
if sys.version_info.major >= 3:
|
||||
# migrate old FEM Gui objects
|
||||
sys.meta_path.append(FemMigrateGui())
|
||||
# migrate old FEM Gui objects
|
||||
sys.meta_path.append(FemMigrateGui())
|
||||
|
||||
|
||||
# add FEM Gui unit tests
|
||||
|
||||
@@ -210,10 +210,7 @@ class SolidSelector(_Selector):
|
||||
foundSolids.add("Solid" + str(solidId + 1))
|
||||
if len(foundSolids) == 1:
|
||||
it = iter(foundSolids)
|
||||
if sys.version_info.major >= 3:
|
||||
return next(it)
|
||||
else:
|
||||
return it.next()
|
||||
return next(it)
|
||||
return None
|
||||
|
||||
def _findSub(self, sub, subList):
|
||||
|
||||
@@ -29,7 +29,6 @@ __url__ = "https://www.freecadweb.org"
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import FreeCAD
|
||||
from FreeCAD import Console
|
||||
@@ -319,8 +318,7 @@ class GmshTools():
|
||||
p1 = subprocess.Popen(["which", "gmsh"], stdout=subprocess.PIPE)
|
||||
if p1.wait() == 0:
|
||||
output = p1.stdout.read()
|
||||
if sys.version_info.major >= 3:
|
||||
output = output.decode("utf-8")
|
||||
output = output.decode("utf-8")
|
||||
gmsh_path = output.split("\n")[0]
|
||||
elif p1.wait() == 1:
|
||||
error_message = (
|
||||
@@ -921,9 +919,7 @@ class GmshTools():
|
||||
stderr=subprocess.PIPE
|
||||
)
|
||||
output, error = p.communicate()
|
||||
if sys.version_info.major >= 3:
|
||||
# output = output.decode("utf-8")
|
||||
error = error.decode("utf-8")
|
||||
error = error.decode("utf-8")
|
||||
# stdout is still cut at some point
|
||||
# but the warnings are in stderr and thus printed :-)
|
||||
# print(output)
|
||||
|
||||
@@ -31,7 +31,6 @@ __url__ = "https://www.freecadweb.org"
|
||||
# \brief FreeCAD FEM _ViewProviderFemMaterial
|
||||
# \brief task panel for common material object
|
||||
|
||||
import sys
|
||||
from PySide import QtCore
|
||||
from PySide import QtGui
|
||||
|
||||
@@ -42,8 +41,7 @@ from FreeCAD import Units
|
||||
from femguiutils import selection_widgets
|
||||
|
||||
|
||||
if sys.version_info.major >= 3:
|
||||
unicode = str
|
||||
unicode = str
|
||||
|
||||
|
||||
class _TaskPanel:
|
||||
|
||||
@@ -29,7 +29,6 @@ __url__ = "https://www.freecadweb.org"
|
||||
# \ingroup FEM
|
||||
# \brief task panel for reinforced material object
|
||||
|
||||
import sys
|
||||
from PySide import QtCore
|
||||
from PySide import QtGui
|
||||
|
||||
@@ -37,8 +36,7 @@ import FreeCAD
|
||||
import FreeCADGui
|
||||
|
||||
|
||||
if sys.version_info.major >= 3:
|
||||
unicode = str
|
||||
unicode = str
|
||||
|
||||
|
||||
class _TaskPanel:
|
||||
@@ -46,8 +44,7 @@ class _TaskPanel:
|
||||
The editmode TaskPanel for MaterialReinforced objects
|
||||
"""
|
||||
|
||||
if sys.version_info.major >= 3:
|
||||
unicode = str
|
||||
unicode = str
|
||||
|
||||
def __init__(self, obj):
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ __url__ = "https://www.freecadweb.org"
|
||||
# \brief task panel for solver ccx tools object
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
from PySide import QtCore
|
||||
from PySide import QtGui
|
||||
@@ -42,9 +41,8 @@ import FreeCADGui
|
||||
|
||||
import FemGui
|
||||
|
||||
if sys.version_info.major >= 3:
|
||||
def unicode(text, *args):
|
||||
return str(text)
|
||||
def unicode(text, *args):
|
||||
return str(text)
|
||||
|
||||
|
||||
class _TaskPanel:
|
||||
@@ -190,25 +188,9 @@ class _TaskPanel:
|
||||
self.femConsoleMessage("CalculiX stdout is empty", "#FF0000")
|
||||
return False
|
||||
|
||||
if sys.version_info.major >= 3:
|
||||
# https://forum.freecadweb.org/viewtopic.php?f=18&t=39195
|
||||
# convert QByteArray to a binary string an decode it to "utf-8"
|
||||
out = out.data().decode() # "utf-8" can be omitted
|
||||
# print(type(out))
|
||||
# print(out)
|
||||
else:
|
||||
try:
|
||||
out = unicode(out, "utf-8", "replace")
|
||||
rx = QtCore.QRegExp("\\*ERROR.*\\n\\n")
|
||||
# print(rx)
|
||||
rx.setMinimal(True)
|
||||
pos = rx.indexIn(out)
|
||||
while not pos < 0:
|
||||
match = rx.cap(0)
|
||||
FreeCAD.Console.PrintError(match.strip().replace("\n", " ") + "\n")
|
||||
pos = rx.indexIn(out, pos + 1)
|
||||
except UnicodeDecodeError:
|
||||
self.femConsoleMessage("Error converting stdout from CalculiX", "#FF0000")
|
||||
# https://forum.freecadweb.org/viewtopic.php?f=18&t=39195
|
||||
# convert QByteArray to a binary string an decode it to "utf-8"
|
||||
out = out.data().decode() # "utf-8" can be omitted
|
||||
out = os.linesep.join([s for s in out.splitlines() if s])
|
||||
out = out.replace("\n", "<br>")
|
||||
# print(out)
|
||||
|
||||
@@ -435,10 +435,7 @@ class FemToolsCcx(QtCore.QRunnable, QtCore.QObject):
|
||||
elif system() in ("Linux", "Darwin"):
|
||||
p1 = subprocess.Popen(["which", "ccx"], stdout=subprocess.PIPE)
|
||||
if p1.wait() == 0:
|
||||
if sys.version_info.major >= 3:
|
||||
ccx_path = p1.stdout.read().decode("utf8").split("\n")[0]
|
||||
else:
|
||||
ccx_path = p1.stdout.read().split("\n")[0]
|
||||
ccx_path = p1.stdout.read().decode("utf8").split("\n")[0]
|
||||
elif p1.wait() == 1:
|
||||
error_message = (
|
||||
"FEM: CalculiX binary ccx not found in "
|
||||
@@ -550,9 +547,8 @@ class FemToolsCcx(QtCore.QRunnable, QtCore.QObject):
|
||||
env=_env
|
||||
)
|
||||
self.ccx_stdout, self.ccx_stderr = p.communicate()
|
||||
if sys.version_info.major >= 3:
|
||||
self.ccx_stdout = self.ccx_stdout.decode()
|
||||
self.ccx_stderr = self.ccx_stderr.decode()
|
||||
self.ccx_stdout = self.ccx_stdout.decode()
|
||||
self.ccx_stderr = self.ccx_stderr.decode()
|
||||
os.putenv("OMP_NUM_THREADS", ont_backup)
|
||||
QtCore.QDir.setCurrent(cwd)
|
||||
return p.returncode
|
||||
@@ -577,9 +573,7 @@ class FemToolsCcx(QtCore.QRunnable, QtCore.QObject):
|
||||
startupinfo=startup_info
|
||||
)
|
||||
ccx_stdout, ccx_stderr = p.communicate()
|
||||
if sys.version_info.major >= 3:
|
||||
ccx_stdout = ccx_stdout.decode()
|
||||
# ccx_stderr = ccx_stderr.decode()
|
||||
ccx_stdout = ccx_stdout.decode()
|
||||
m = re.search(r"(\d+).(\d+)", ccx_stdout)
|
||||
return (int(m.group(1)), int(m.group(2)))
|
||||
|
||||
|
||||
@@ -71,10 +71,7 @@ def importFCMat(fileName):
|
||||
)
|
||||
Config = configparser.RawConfigParser()
|
||||
Config.optionxform = str
|
||||
if sys.version_info.major >= 3:
|
||||
Config.read(fileName, encoding='utf-8') # respect unicode filenames
|
||||
else:
|
||||
Config.read(fileName)
|
||||
Config.read(fileName, encoding='utf-8') # respect unicode filenames
|
||||
dict1 = {}
|
||||
for section in Config.sections():
|
||||
options = Config.options(section)
|
||||
|
||||
@@ -25,7 +25,6 @@ __author__ = "Yorik van Havre, Bernd Hahnebach"
|
||||
__url__ = "http://www.freecadweb.org"
|
||||
|
||||
import os
|
||||
import sys
|
||||
from PySide import QtCore, QtGui, QtSvg
|
||||
|
||||
import FreeCAD
|
||||
@@ -33,8 +32,7 @@ import FreeCADGui
|
||||
# import Material_rc
|
||||
|
||||
# is this still needed after the move to card utils???
|
||||
if sys.version_info.major >= 3:
|
||||
unicode = str
|
||||
unicode = str
|
||||
|
||||
|
||||
# ************************************************************************************************
|
||||
|
||||
@@ -24,14 +24,12 @@ __author__ = "Bernd Hahnebach"
|
||||
__url__ = "http://www.freecadweb.org"
|
||||
|
||||
import os
|
||||
import sys
|
||||
from os.path import join
|
||||
|
||||
import FreeCAD
|
||||
|
||||
|
||||
if sys.version_info.major >= 3:
|
||||
unicode = str
|
||||
unicode = str
|
||||
|
||||
|
||||
# TODO:
|
||||
|
||||
Reference in New Issue
Block a user