med_file_mesh = MEDFileMesh.New(file_path)
groups = list(med_file_mesh.getGroupsOnSpecifiedLev(-1))
except Exception as e:
- print e.what()
+ print(e.what())
return []
return groups
def get_preset_name(presets, lihbor, liubor, livbor, litbor):
name = 'Custom'
res = (lihbor, liubor, livbor, litbor)
- for key, val in presets.iteritems():
+ for key, val in presets.items():
if val == res:
name = key
break
def on_apply(self):
# Save boundary conditions file
if not self.is_valid():
- print 'Not valid'
+ print('Not valid')
return False
if self.sameAsInputCB.isChecked():
file_path = self.bndConditionsFileEdit.text()
else:
file_path = self.resultBndConditionsFileEdit.text()
- print 'File path:', file_path
+ print('File path:', file_path)
writer = boundaryConditions.BoundaryConditionWriter(file_path)
conditions = []
- for row_nb in xrange(0, self.boundaryConditionsTable.rowCount()):
+ for row_nb in range(0, self.boundaryConditionsTable.rowCount()):
lihbor = str(self.boundaryConditionsTable.item(row_nb, 1).text())
liubor = str(self.boundaryConditionsTable.item(row_nb, 2).text())
livbor = str(self.boundaryConditionsTable.item(row_nb, 3).text())
preset = str(combo.currentText())
- if preset and self.presets.has_key(preset):
+ if preset and preset in self.presets:
values = self.presets[preset]
row_nb = combo.property(ROW_PROPERTY_NAME)
combo = QComboBox(self)
#combo.addItem('')
if len(self.presets) > 0:
- items = self.presets.keys()
+ items = list(self.presets.keys())
items.sort()
combo.addItems(items)
is_updated = False
nb_rows = self.boundaryConditionsTable.rowCount()
- for row_nb in xrange(0, nb_rows):
+ for row_nb in range(0, nb_rows):
group_name = str(self.boundaryConditionsTable.item(row_nb, 5).text())
- if self.input_conditions.has_key(group_name):
+ if group_name in self.input_conditions:
values = self.input_conditions[group_name]
#print values
elif len(self.get_output_path())==0:
QMessageBox.critical(self, self.tr("Insufficient input data"), self.tr("Output file path is empty."))
else:
- for row_nb in xrange(0, self.boundaryConditionsTable.rowCount()):
+ for row_nb in range(0, self.boundaryConditionsTable.rowCount()):
has_empty_cells = True
lihbor = str(self.boundaryConditionsTable.item(row_nb, 1).text())
liubor = str(self.boundaryConditionsTable.item(row_nb, 2).text())
###
def _setContext(studyID):
global __study2context__, __current_context__
- if not __study2context__.has_key(studyID):
+ if studyID not in __study2context__:
__study2context__[studyID] = GUIcontext()
pass
__current_context__ = __study2context__[studyID]
def OnGUIEvent(commandID):
try:
dict_command[commandID]()
- except HSGUIException, exc:
+ except HSGUIException as exc:
QMessageBox.critical(sgPyQt.getDesktop(),
QApplication.translate("OnGUIEvent", "Error"),
- unicode(exc))
+ str(exc))
except:
logger.exception("Unhandled exception caught in HYDROSOLVER GUI")
msg = QApplication.translate("OnGUIEvent",
ed = hydro_study.HydroStudyEditor()
sobj = get_and_check_selected_file_path()
ed.generate_study_script(sobj)
- except SALOME.SALOME_Exception, exc:
+ except SALOME.SALOME_Exception as exc:
salome.sg.updateObjBrowser(0)
- msg = unicode(QApplication.translate("generate_telemac2d_python",
+ msg = str(QApplication.translate("generate_telemac2d_python",
"An error happened while trying to generate telemac2d Python script:"))
msg += "\n" + exc.details.text
raise HSGUIException(msg)
ed = hydro_study.HydroStudyEditor()
sobj = get_and_check_selected_file_path()
ed.generate_study_yacs(sobj)
- except SALOME.SALOME_Exception, exc:
+ except SALOME.SALOME_Exception as exc:
salome.sg.updateObjBrowser(0)
- msg = unicode(QApplication.translate("generate_telemac2d_yacs",
+ msg = str(QApplication.translate("generate_telemac2d_yacs",
"An error happened while trying to generate telemac2d Python script:"))
msg += "\n" + exc.details.text
raise HSGUIException(msg)
self._errors.append("Line #%s: wrong number of values in the preset." % line_number)
elif values[0].strip() == "":
self._errors.append("Line #%s: empty name of the preset." % line_number)
- elif presets.has_key(values[0]):
+ elif values[0] in presets:
self._errors.append("Line #%s: preset name %s is already used." % (line_number, values[0]))
else:
name = values[0]
medenum.MED_NODE, medenum.MED_NONE,
medenum.MED_FULL_INTERLACE, medenum.MED_ALL_CONSTITUENT, len(values), values)
- print "MED field '%s' on %s nodes has been created." % (med_field_name, nb_nodes)
+ print("MED field '%s' on %s nodes has been created." % (med_field_name, nb_nodes))
# close MED file
medfile.MEDfileClose(fid)
\ No newline at end of file
import HYDROPy
from salome.hydrotools.interpolS import assignStrickler
-from generate_interpolz import replace
+from .generate_interpolz import replace
from PyQt5.QtWidgets import QDialog, QFileDialog, QTableWidgetItem, QComboBox, QMessageBox
from PyQt5 import uic
Method __convert__ is redefined to skip the test on the string length.
"""
def __convert__(cls, valeur):
- if isinstance(valeur, (str, unicode)):
+ if isinstance(valeur, str):
return valeur.strip()
raise ValueError(_('A string is expected'))
BOUNDARY_CONDITION = PROC(
nom = "BOUNDARY_CONDITION", op = None,
- fr = u"Définition d'une condition limite pour Telemac2D",
- ang = u"Definition of a boundary condition for Telemac2D",
+ fr = "Définition d'une condition limite pour Telemac2D",
+ ang = "Definition of a boundary condition for Telemac2D",
GROUP = SIMP(statut = "o", typ = grma,
- fr = u"Groupe sur lequel la condition limite est définie",
- ang = u"Group on which the boundary condition is defined",
+ fr = "Groupe sur lequel la condition limite est définie",
+ ang = "Group on which the boundary condition is defined",
),
LIHBOR = SIMP(statut = "o", typ = "I",
- fr = u"Type de condition limite pour la hauteur d'eau",
- ang = u"Boundary condition type for the water height",
+ fr = "Type de condition limite pour la hauteur d'eau",
+ ang = "Boundary condition type for the water height",
),
LIUBOR = SIMP(statut = "o", typ = "I",
- fr = u"Type de condition limite pour la composante U de la vitesse",
- ang = u"Boundary condition type for the U component of the water velocity",
+ fr = "Type de condition limite pour la composante U de la vitesse",
+ ang = "Boundary condition type for the U component of the water velocity",
),
LIVBOR = SIMP(statut = "o", typ = "I",
- fr = u"Type de condition limite pour la composante V de la vitesse",
- ang = u"Boundary condition type for the V component of the water velocity",
+ fr = "Type de condition limite pour la composante V de la vitesse",
+ ang = "Boundary condition type for the V component of the water velocity",
),
)
TEXTE_NEW_JDC="BOUNDARY_CONDITION()"
del lines[i]
name = pattern[1:-1]
lines.insert( i, "%s = {}\n" % name )
- keys = subst.keys()
+ keys = list(subst.keys())
keys.sort()
i = i+1
for k in keys:
import libSALOME_Swig
salome_gui = libSALOME_Swig.SALOMEGUI_Swig()
-from generate_interpolz import generate, generate_B
+from .generate_interpolz import generate, generate_B
def get_med_groups( file_path ):
#print "get_med_groups", file_path
#meshes = MEDLoader.GetMeshNames(file_path)
(meshes, status) = smesh.CreateMeshesFromMED(file_path)
except:
- print 'No meshes found'
+ print('No meshes found')
return []
if len(meshes)==0:
- print 'No mesh found'
+ print('No mesh found')
return []
mesh1 = meshes[0]
- print 'Found mesh:', mesh1
+ print('Found mesh:', mesh1)
try:
#groups = list(MEDLoader.GetMeshGroupsNames(file_path, mesh1))
grps = mesh1.GetGroups()
groups = [grp.GetName() for grp in grps if grp.GetType() == SMESH.FACE]
if len(groups) == 0:
- print "Problem! There are no groups of faces in the mesh!"
- print "Please create at least the groups of faces corresponding to each region of the HYDRO case"
+ print("Problem! There are no groups of faces in the mesh!")
+ print("Please create at least the groups of faces corresponding to each region of the HYDRO case")
return []
- print 'Found groups:', groups
+ print('Found groups:', groups)
except:
- print 'No groups found'
+ print('No groups found')
return []
return groups
def onMEDChanged( self ):
self.med_groups = get_med_groups( str(self.MEDFile.text()) )
- print self.med_groups
+ print(self.med_groups)
n = len( self.med_groups )
self.Groups.setRowCount( n )
self.medGroupNames.clear()
def onApply( self ):
path = str(self.OutputPath.text())
med_file = str(self.MEDFile.text())
- print 'current TAB = ', self.tabWidget.currentIndex()
+ print('current TAB = ', self.tabWidget.currentIndex())
if self.tabWidget.currentIndex() == 0: #calc case tab
calc_case = str(self.CalcCase.text())
med_groups_regions = {}
"""
try:
self.ed.find_or_create_param_study(jdcPath)
- except Exception, exc:
+ except Exception as exc:
msgError = "Can't add file to Salome study tree"
logger.exception(msgError)
QMessageBox.warning(self, self.tr("Warning"),
self.ntuple=ntuple
def __convert__(self,valeur):
- if type(valeur) == types.StringType:
+ if type(valeur) == bytes:
return None
if len(valeur) != self.ntuple:
return None
TELEMAC2D = PROC(
nom = "TELEMAC2D", op = None,
- fr = u"Définition d'un cas d'étude Telemac2D",
- ang = u"Definition of a Telemac2D study case",
+ fr = "Définition d'un cas d'étude Telemac2D",
+ ang = "Definition of a Telemac2D study case",
STEERING_FILE = SIMP(statut = "o", typ = 'Fichier',
- fr = u"Fichier de description du cas",
- ang = u"Case description file",
+ fr = "Fichier de description du cas",
+ ang = "Case description file",
),
USER_FORTRAN = SIMP(statut = "f", typ = 'FichierOuRepertoire',
fr = "Fichier Fortran utilisateur",
- ang = u"Fortran user file",
+ ang = "Fortran user file",
),
WORKING_DIRECTORY = SIMP(statut = "o", typ = 'Repertoire',
defaut = '/tmp',
fr = "Repertoire de travail",
- ang = u"Working directory user file",
+ ang = "Working directory user file",
),
RESULT_DIRECTORY = SIMP(statut = "f", typ = 'Repertoire',
fr = "Repertoire de travail",
- ang = u"Working directory user file",
+ ang = "Working directory user file",
),
RESULTS_FILE_NAME = SIMP(statut = "f", typ = 'TXM',
- fr = u"Fichier des resultats (Ecrasera celui dans le fichier cas)",
- ang = u"Results file (Will replace the one in the steering file)"
+ fr = "Fichier des resultats (Ecrasera celui dans le fichier cas)",
+ ang = "Results file (Will replace the one in the steering file)"
),
Consigne = SIMP(statut ="o", homo="information", typ="TXM",
defaut = "All index are in Python numbering (Starting from 0)",
),
INPUT_VARIABLE = FACT(statut = 'f', max = '**',
- fr = u"Variable d'entrée du calcul",
- ang = u"Computation input variable",
+ fr = "Variable d'entrée du calcul",
+ ang = "Computation input variable",
NAME = SIMP(statut = "o", typ = 'TXM',
- fr = u"Nom de la variable (format Python)",
- ang = u"Variable name (Python format)"
+ fr = "Nom de la variable (format Python)",
+ ang = "Variable name (Python format)"
),
VAR_INFO = FACT(statut = "o",
- fr = u'Variable du modèle Telemac2D',
- ang = u'Telemac2D model variable',
+ fr = 'Variable du modèle Telemac2D',
+ ang = 'Telemac2D model variable',
VAR_NAME = SIMP(statut = "o", typ = 'TXM',
intoSug = get_list_var_api('TELEMAC2D'),
- fr = u'Nom de la variable du modèle (ex: "MODEL.DEBIT")',
- ang = u'Model variable name (ex: "MODEL.DEBIT")'
+ fr = 'Nom de la variable du modèle (ex: "MODEL.DEBIT")',
+ ang = 'Model variable name (ex: "MODEL.DEBIT")'
),
DEFAULT_VALUE = SIMP(statut = "o", typ = 'TXM',
- fr = u'Valeur par défaut',
- ang = u'Default value',
+ fr = 'Valeur par défaut',
+ ang = 'Default value',
),
ZONE_DEF = FACT(statut = "o",
- ang = u'Variable definition area',
- fr = u'Zone de définition de la variable',
+ ang = 'Variable definition area',
+ fr = 'Zone de définition de la variable',
TYPE = SIMP(statut = "o", typ = 'TXM',
into = ['INDEX', 'RANGE', 'POLYGON', 'POLYGON_FILE'],
fenetreIhm="menuDeroulant",
- fr = u'Type de definition de la variable',
- ang = u'Type of definition for the variable',
+ fr = 'Type de definition de la variable',
+ ang = 'Type of definition for the variable',
),
b_INDEX = BLOC(condition = "TYPE == 'INDEX'",
INDEX = SIMP(statut = "o", typ = Tuple(3),
defaut = (0, 0, 0),
ang = "Index of the variable",
- fr = u"Indice de la variable",
+ fr = "Indice de la variable",
validators = VerifTypeTuple(('I', 'I', 'I')),
),
),
b_RANGE = BLOC(condition = "TYPE == 'RANGE'",
RANGE = SIMP(statut = "o", typ = 'TXM',
- fr = u"Liste d'index pour des tableaux à une dimension ex: [1,3:8,666]",
+ fr = "Liste d'index pour des tableaux à une dimension ex: [1,3:8,666]",
ang = "Range of index for one dimension arrays ex: [1,3:8,666]",
),
Consigne = SIMP(statut ="o", homo="information", typ="TXM",
POLYGON = SIMP(statut = "o",
typ = Tuple(2),
max = '**',
- fr = u"Liste des sommets (coordonnées X,Y) du "
- u"polygone définissant le contour de la zone",
+ fr = "Liste des sommets (coordonnées X,Y) du "
+ "polygone définissant le contour de la zone",
ang = "List of points (X,Y coordinates) of the "
"polygon defining the border of the area",
validators = VerifTypeTuple(('R', 'R')),
),
b_POLYGON_FILE = BLOC(condition = "TYPE == 'POLYGON_FILE'",
POLYGON_FILE = FACT(statut = "o",
- fr = u"Polygon dans un fichier",
+ fr = "Polygon dans un fichier",
ang = "Polygone in a file",
FILE_NAME = SIMP(statut = "o", typ = 'Fichier',
- fr = u"Fichier contenant les info du polygone",
+ fr = "Fichier contenant les info du polygone",
ang = "File containing the polygon info",
),
SEPARATOR = SIMP(statut = "o", typ = 'TXM',
defaut = ',',
- fr = u"Separateur pour le fichier de polygone",
+ fr = "Separateur pour le fichier de polygone",
ang = "Separator for the polygon file",
),
),
),
),
OUTPUT_VARIABLE = FACT(statut = 'f', max = '**',
- fr = u"Variable de sortie du calcul",
- ang = u"Computation output variable",
+ fr = "Variable de sortie du calcul",
+ ang = "Computation output variable",
NAME = SIMP(statut = "o", typ = 'TXM',
- fr = u"Nom de la variable",
- ang = u"Variable name",
+ fr = "Nom de la variable",
+ ang = "Variable name",
),
VAR_INFO = FACT(statut = "o",
- fr = u'Variable du modèle Telemac2D',
- ang = u'Telemac2D model variable',
+ fr = 'Variable du modèle Telemac2D',
+ ang = 'Telemac2D model variable',
VAR_NAME = SIMP(statut = "o", typ = 'TXM',
intoSug = get_list_var_api('TELEMAC2D'),
- fr = u'Nom de la variable du modèle (ex: "MODEL.DEBIT")',
- ang = u'Model variable name (ex: "MODEL.DEBIT")',
+ fr = 'Nom de la variable du modèle (ex: "MODEL.DEBIT")',
+ ang = 'Model variable name (ex: "MODEL.DEBIT")',
),
ZONE_DEF = FACT(statut = "o",
- ang = u'Variable definition area',
- fr = u'Zone de définition de la variable',
+ ang = 'Variable definition area',
+ fr = 'Zone de définition de la variable',
INDEX = SIMP(statut = "o", typ = Tuple(3),
defaut = (0, 0, 0, ),
ang = "Index of the point / border",
- fr = u"Indice du point ou de la frontière",
+ fr = "Indice du point ou de la frontière",
validators = VerifTypeTuple(('I', 'I', 'I')),
),
),
"""
try:
self.ed.find_or_create_run_study(jdcPath)
- except Exception, exc:
+ except Exception as exc:
msgError = "Can't add file to Salome study tree"
logger.exception(msgError)
QMessageBox.warning(self, self.tr("Warning"),
)
RUN_STUDY = PROC(
nom = "RUN_STUDY", op = None,
- fr = u"Définition d'un cas pour le lanceur Python",
- ang = u"Definition of a case for the Python launcher",
+ fr = "Définition d'un cas pour le lanceur Python",
+ ang = "Definition of a case for the Python launcher",
CODE = SIMP(statut = "o", typ = "TXM", into = codelist, defaut = "telemac2d",
- fr = u"Code à exécuter",
- ang = u"Code to run"),
+ fr = "Code à exécuter",
+ ang = "Code to run"),
FICHIER_CAS = SIMP(statut = "o", typ = 'Fichier',
- fr = u"Fichier de description du cas",
- ang = u"Case description file"),
+ fr = "Fichier de description du cas",
+ ang = "Case description file"),
REPERTOIRE_TRAVAIL = SIMP(statut = "f", typ = 'Repertoire',
- fr = u"Répertoire de travail",
- ang = u"Working directory"),
+ fr = "Répertoire de travail",
+ ang = "Working directory"),
)
TEXTE_NEW_JDC="RUN_STUDY()"
from salome.hydro.study import jdc_to_dict
from salome.hydro.run_study.eficas.appli import EficasForRunStudyAppli
-from launcher import run_study
-from genjobwindow import GenJobDialog
+from .launcher import run_study
+from .genjobwindow import GenJobDialog
from PyQt5.QtWidgets import QFileDialog
# Launch the command
logger.debug("Running the following command in xterm: %s" % cmd)
args = ["xterm", "-T", "Execution of Telemac", "-geo", "80x60", "-hold", "-l", "-e", cmd]
- if param_dict.has_key('batchExec'):
+ if 'batchExec' in param_dict:
if param_dict['batchExec'] == True:
args = ["xterm", "-T", "Execution of Telemac", "-geo", "80x60", "+hold", "-l", "-e", cmd]
subprocess.Popen(args, cwd = wrkdir)
context = {}
for command in command_list:
context[command] = _args_to_dict
- exec "parameters = " + jdc.strip() in context
+ exec("parameters = " + jdc.strip(), context)
return context['parameters']
def _args_to_dict(**kwargs):
return kwargs
def get_jdc_dict_var_as_tuple(jdc_dict, varname):
- if not jdc_dict.has_key(varname):
+ if varname not in jdc_dict:
return tuple()
- elif not isinstance(jdc_dict[varname], types.TupleType):
+ elif not isinstance(jdc_dict[varname], tuple):
return (jdc_dict[varname],)
else:
return jdc_dict[varname]
"""
try:
self.ed.find_or_create_telma(jdcPath)
- except Exception, exc:
+ except Exception as exc:
msgError = "Can't add file to Salome study tree"
logger.exception(msgError)
QMessageBox.warning(self, self.tr("Warning"),
-from interpolz_gui import InterpolzDlg
+from .interpolz_gui import InterpolzDlg
dlg = InterpolzDlg()
dlg.show()
presets = reader.read()
self.assertEqual(3, len(presets))
- self.assertEqual(True, presets.has_key("Closed boundaries/walls"))
+ self.assertEqual(True, "Closed boundaries/walls" in presets)
self.assertEqual((2,2,2,2), presets["Closed boundaries/walls"])
- self.assertEqual(True, presets.has_key("Incident waves"))
+ self.assertEqual(True, "Incident waves" in presets)
self.assertEqual((1,1,1,None), presets["Incident waves"])
- self.assertEqual(True, presets.has_key("Free T"))
+ self.assertEqual(True, "Free T" in presets)
self.assertEqual((None,None,None,4), presets["Free T"])
def testRead(self):