import sys, os, shutil, pickle, tempfile
-import main, genereCrack, Zset
-import utilityFunctions as uF
+from Zcracks import main, genereCrack, Zset
+from Zcracks import utilityFunctions as uF
+ os.environ['QT_QPA_PLATFORM_PLUGIN_PATH']=os.path.join(os.environ['QTDIR'],'plugins','platforms')
+
+ if 'MESHGEMSHOME' in os.environ:
+ meshgemsdir=os.environ['MESHGEMSHOME']
+ if len(meshgemsdir) > 0:
+ meshgems=meshgemsdir.split(os.sep)[-1]
+ uF.removeFromSessionPath('LD_LIBRARY_PATH', meshgems)
+
#commande="/bin/bash -c ""source $HOME/zebulon/Z8.6.6_NEW/do_config_bash"""
#os.system(commande)
if data==None: data=pickle.load(open(dataFile,'r'))
- print data
+ print(data)
- tmpdir=tempfile.mkdtemp()
- uF.removeFromSessionPath('LD_LIBRARY_PATH', 'Meshgems-2111')
+ tmpdir=tempfile.mkdtemp(prefix='tmpZcracks')
if names==None: names={'saneGeoName':'salome_sane', 'crackGeoName':'salome_crack', 'crackedGeoName':'salome_cracked'}
#tmpdir = "/local00/home/B27118/projets/Zcracks/Zcracks/casTests/tmpdir"
#if not os.path.isdir(tmpdir): os.mkdir(tmpdir)
- tmpdir=tempfile.mktemp(prefix='tmpZcracks')
+ tmpdir=tempfile.mkdtemp(prefix='tmpZcracks')
-print "tmpdir=", tmpdir
+print("tmpdir=", tmpdir)
- meshgemsdir=os.environ('MESHGEMSHOME')
- if len(meshgemsdir) > 0:
- meshgems=string.split(meshgemsdir,os.sep)[-1]
- uF.removeFromSessionPath('LD_LIBRARY_PATH', meshgems)
+ #meshgemsdir=os.environ('MESHGEMSHOME')
+ #if len(meshgemsdir) > 0:
+ #meshgems=string.split(meshgemsdir,os.sep)[-1]
+ #uF.removeFromSessionPath('LD_LIBRARY_PATH', meshgems)
def LAUNCH(listCas=[]):
- if type(listCas)!=list: listCas=[listCas]
+ if not isinstance(listCas, list): listCas=[listCas]
N=20
L=1.
OK=[]
NOOK=[]
- for s in list(synthese.keys()):
- for s in synthese.keys():
++ for s in synthese:
if synthese[s]:
OK.append(s)
else:
import sys, pickle, tempfile, shutil
from os import path, getpid, environ, remove, system
- try:
- from PyQt5.QtCore import *
- from PyQt5.QtGui import *
- from PyQt5.QtWidgets import *
- except:
- from PyQt4.QtCore import *
- from PyQt4.QtGui import *
+ from PyQt5.QtCore import *
+ from PyQt5.QtGui import *
+ from PyQt5.QtWidgets import *
-import utilityFunctions as uF
-import genereCrack, Zset, output, zcracks_ui
+from . import utilityFunctions as uF
+from . import genereCrack, Zset, output, zcracks_ui
-from output import message, init
-from zcracks_ui import Ui_Zui
+from .output import message, init
+from .zcracks_ui import Ui_Zui
# ---------------------
for cont, obj in enumerate(self.lineEditObjects):
if self.lineEditTypes[cont] in [float, int]:
- obj.setText(QString(self.data['TXT'+self.lineEditNames[cont]]))
+ obj.setText(self.data['TXT'+self.lineEditNames[cont]])
else:
- obj.setText(QString(self.data[self.lineEditNames[cont]]))
+ obj.setText(self.data[self.lineEditNames[cont]])
- self.ui.CBQuad.setChecked(True if 'quad' in self.data.keys() and self.data['quad'] else False)
- self.ui.CBBarsoum.setChecked(True if 'barsoum' in self.data.keys() and self.data['barsoum'] else False)
- self.ui.CBIs2D.setChecked(True if 'is2D' in self.data.keys() and self.data['is2D'] else False)
- self.ui.CBRefine.setChecked(True if 'refine' in self.data.keys() and self.data['refine'] else False)
+ self.ui.CBQuad.setChecked(True if 'quad' in list(self.data.keys()) and self.data['quad'] else False)
+ self.ui.CBBarsoum.setChecked(True if 'barsoum' in list(self.data.keys()) and self.data['barsoum'] else False)
+ self.ui.CBIs2D.setChecked(True if 'is2D' in list(self.data.keys()) and self.data['is2D'] else False)
+ self.ui.CBRefine.setChecked(True if 'refine' in list(self.data.keys()) and self.data['refine'] else False)
-
-
-
-
- #if self.data['quad']: self.ui.CBQuad.setChecked(True)
- #if self.data['barsoum']: self.ui.CBBarsoum.setChecked(True)
- #if self.data['is2D']: self.ui.CBIs2D.setChecked(True)
- #if self.data['refine']: self.ui.CBRefine.setChecked(True)
self.setTableParameters()
"""
# if the entry already exists, we remove it to replace by a
# new one
- if meshName in self.__dictInputData:
- if self.__dictInputFiles.has_key(meshName):
++ if meshName in self.__dictInputFiles:
self.__delInputFromMap(meshName)
inputData = InputData()
else:
self.__nbSteelbarMesh -= 1
- print inputData
- print "nb concrete mesh ",self.__nbConcreteMesh
- print "nb steelbar mesh ",self.__nbSteelbarMesh
+ print(inputData)
+ print("nb concrete mesh ",self.__nbConcreteMesh)
+ print("nb steelbar mesh ",self.__nbSteelbarMesh)
- def setData(self, listInputData=[]):
+ def setData(self, dictInputData={}):
"""
This function fills the dialog widgets with values provided by
the specified data list.
"""
self.clear()
- for inputData in listInputData:
- if dictInputData.has_key(INPUTDATA_KEY_FILES):
++ if INPUTDATA_KEY_FILES in dictInputData:
+ listInputData = dictInputData["meshfiles"]
+ for inputData in listInputData:
- meshName = inputData.meshName
- meshObject = inputData.meshObject
- meshType = inputData.meshType
- groupName = inputData.groupName
- meshName = inputData.meshName
++ meshName = inputData.meshName
+ meshObject = inputData.meshObject
- meshType = inputData.meshType
- groupName = inputData.groupName
++ meshType = inputData.meshType
++ groupName = inputData.groupName
- self.__addInputInGui(meshName, meshObject, meshType, groupName)
- self.__addInputInMap(meshName, meshObject, meshType, groupName)
+ self.__addInputInGui(meshName, meshObject, meshType, groupName)
+ self.__addInputInMap(meshName, meshObject, meshType, groupName)
- if not DEBUG_MODE:
- self.onSelectSmeshObject()
+ if not DEBUG_MODE:
+ self.onSelectSmeshObject()
+
- if dictInputData.has_key(INPUTDATA_KEY_PARAM):
- dictInputParameters = dictInputData[INPUTDATA_KEY_PARAM]
- if dictInputParameters.has_key(PARAM_KEY_NBITER):
++ if INPUTDATA_KEY_PARAM in dictInputData:
++ dictInputParameters = dictInputData[INPUTDATA_KEY_PARAM]
++ if PARAM_KEY_NBITER in dictInputParameters:
+ self.__ui.txtParamNbIter.setValue(dictInputParameters[PARAM_KEY_NBITER])
- if dictInputParameters.has_key(PARAM_KEY_RMAXRMIN):
++ if PARAM_KEY_RMAXRMIN in dictInputParameters:
+ self.__ui.txtParamRminRmax.setValue(dictInputParameters[PARAM_KEY_RMAXRMIN])
def getData(self):
"""
from qtsalome import QDialog, QIcon, Qt
-from plugindialog_ui import Ui_PluginDialog
-from inputdialog import InputDialog, INPUTDATA_KEY_FILES, INPUTDATA_KEY_PARAM
-from inputdialog import PARAM_KEY_NBITER, PARAM_KEY_RMAXRMIN
-from inputdata import InputData
+from salome.smesh.spadder.gui.plugindialog_ui import Ui_PluginDialog
- from salome.smesh.spadder.gui.inputdialog import InputDialog
++from salome.smesh.spadder.gui.inputdialog import InputDialog, INPUTDATA_KEY_FILES, INPUTDATA_KEY_PARAM
++from salome.smesh.spadder.gui.inputdialog import PARAM_KEY_NBITER, PARAM_KEY_RMAXRMIN
+from salome.smesh.spadder.gui.inputdata import InputData
# __GBO__: uncomment this line and comment the previous one to use the
# demo input dialog instead of the real one.
#from demoinputdialog import InputDialog
group_name = inputData.groupName)
meshJobFileList.append(parameter)
- for inputParameterKey in self.__dictInputParameters.keys():
+ # And to create a list of the additional parameters.
+ # WARN: the CORBA interface requires string values.
+ meshJobParameterList=[]
++ for inputParameterKey in self.__dictInputParameters:
+ value = self.__dictInputParameters[inputParameterKey]
+ parameter = MESHJOB.MeshJobParameter(name=inputParameterKey,value=str(value))
+ meshJobParameterList.append(parameter)
+
jobManager = self.__getJobManager()
- self.__jobid = jobManager.initialize(meshJobFileList, self.__configId)
+ self.__jobid = jobManager.initialize(meshJobFileList, meshJobParameterList, self.__configId)
if self.__jobid < 0:
self.__log("ERR: the job can't be initialized")
self.__log("ERR: %s"%jobManager.getLastErrorMessage())
jobid = component.initialize(meshJobFileList, meshJobParameterList, configId)
if jobid<0:
msg = component.getLastErrorMessage()
- print "ERR: %s"%msg
+ print("ERR: %s"%msg)
sys.exit(1)
-
+
created = False
nbiter = 0
while not created:
ended=True
time.sleep(0.5)
nbiter+=1
-
+
if state not in end_states:
- print "ERR: jobid = "+str(jobid)+" ended abnormally with state="+str(state)
+ print("ERR: jobid = "+str(jobid)+" ended abnormally with state="+str(state))
msg = component.getLastErrorMessage()
- print("ERR: %s"%msg)
- print "ERR: %s"%msg
++ print("ERR: %s"%msg)
else:
- print "OK: jobid = "+str(jobid)+" ended with state="+str(state)
+ print("OK: jobid = "+str(jobid)+" ended with state="+str(state))
meshJobResults = component.finalize(jobid)
- print meshJobResults
+ print(meshJobResults)
if meshJobResults.status is not True:
- print "ERR: the results are not OK: %s"%component.getLastErrorMessage()
- print "ERR: see log files in %s"%meshJobResults.results_dirname
+ print("ERR: the results are not OK: %s"%component.getLastErrorMessage())
+ print("ERR: see log files in %s"%meshJobResults.results_dirname)