Python script for HOMARD
Test test_1
"""
-__revision__ = "V4.01"
+__revision__ = "V4.03"
#========================================================================
TEST_NAME = "test_1"
N_ITER_TEST_FILE = 3
#========================================================================
import os
-import tempfile
import sys
import HOMARD
import salome
REP_PYTHON = os.path.join(PATH_HOMARD, "bin", "salome", "test", "HOMARD")
REP_PYTHON = os.path.normpath(REP_PYTHON)
sys.path.append(REP_PYTHON)
-from test_util import remove_dir
+from test_util import get_dir
from test_util import test_results
-# Repertoire des donnees du test
-REP_DATA = os.path.join(PATH_HOMARD, "share", "salome", "homardsamples")
-REP_DATA = os.path.normpath(REP_DATA)
-# Repertoire des resultats
-if DEBUG :
- DIRCASE = os.path.join("/tmp", TEST_NAME)
- if ( os.path.isdir(DIRCASE) ) :
- remove_dir(DIRCASE)
- os.mkdir(DIRCASE)
-else :
- DIRCASE = tempfile.mkdtemp()
+# ==================================
+# Répertoires pour ce test
+REP_DATA, DIRCASE = get_dir(PATH_HOMARD, TEST_NAME, DEBUG)
# ==================================
salome.salome_init()
#
#========================================================================
#========================================================================
-def homard_exec(theStudy):
+def homard_exec():
"""
Python script for HOMARD
"""
#
while not error :
#
- HOMARD.SetCurrentStudy(theStudy)
+ HOMARD.UpdateStudy()
#
# Creation of the zones
# =====================
zones_1_et_2.AddZone('Zone_1_1', 1)
zones_1_et_2.AddZone('Zone_1_2', 1)
laux = zones_1_et_2.GetZones()
- nbzone = len(laux)/2
- jaux = 0
- for iaux in range(nbzone) :
- print(hyponame_2, " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux])
- jaux += 2
+ nbzone = len(laux) // 2
+ iaux = 0
+ for _ in range(nbzone) :
+ print(hyponame_2, " : ", dico[laux[iaux+1]], "sur la zone", laux[iaux])
+ iaux += 2
print(hyponame_2, " : champ utilisé :", zones_1_et_2.GetFieldName())
if ( len (zones_1_et_2.GetFieldName()) > 0 ) :
print(".. caractéristiques de l'adaptation :", zones_1_et_2.GetField())
# Exec of HOMARD-SALOME
#
try :
- ERROR = homard_exec(salome.myStudy)
+ ERROR = homard_exec()
if ERROR :
raise Exception('Pb in homard_exec at iteration %d' %ERROR )
-except Exception as eee:
- raise Exception('Pb in homard_exec: '+eee.message)
+except RuntimeError as eee:
+ raise Exception('Pb in homard_exec: '+str(eee.message))
#
# Test of the results
#
test_results(REP_DATA, TEST_NAME, DIRCASE, N_ITER_TEST_FILE, N_REP_TEST_FILE, DESTROY_DIR)
#
if salome.sg.hasDesktop():
- salome.sg.updateObjBrowser(True)
+ salome.sg.updateObjBrowser()
iparameters.getSession().restoreVisualState(1)