From: Gerald NICOLAS Date: Wed, 10 Jan 2018 10:02:50 +0000 (+0100) Subject: Mutualisation de recherche de répertoire X-Git-Tag: V8_5_0a1~2^2~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=006b17c64a532b9b00f44ea9ef1605653cbcbf2f;p=modules%2Fhomard.git Mutualisation de recherche de répertoire --- diff --git a/src/tests/Test/test_1.py b/src/tests/Test/test_1.py index 01055418..35a0648d 100755 --- a/src/tests/Test/test_1.py +++ b/src/tests/Test/test_1.py @@ -21,7 +21,7 @@ Python script for HOMARD Test test_1 """ -__revision__ = "V4.01" +__revision__ = "V4.02" #======================================================================== TEST_NAME = "test_1" @@ -29,7 +29,6 @@ DEBUG = False N_ITER_TEST_FILE = 3 #======================================================================== import os -import tempfile import sys import HOMARD import salome @@ -40,19 +39,11 @@ PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') 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(prefix=TEST_NAME) +# ================================== +# Répertoires pour ce test +REP_DATA, DIRCASE, DATA_TUTORIAL = get_dir(PATH_HOMARD, TEST_NAME, DEBUG) # ================================== salome.salome_init() @@ -107,11 +98,11 @@ Python script for HOMARD 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()) @@ -205,8 +196,8 @@ try : ERROR = homard_exec(salome.myStudy) 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 # diff --git a/src/tests/Test/test_2.py b/src/tests/Test/test_2.py index 5183eca0..b82a862d 100755 --- a/src/tests/Test/test_2.py +++ b/src/tests/Test/test_2.py @@ -21,7 +21,7 @@ Python script for HOMARD Test test_2 """ -__revision__ = "V4.01" +__revision__ = "V4.02" #======================================================================== TEST_NAME = "test_2" @@ -29,7 +29,6 @@ DEBUG = False N_ITER_TEST_FILE = 3 #======================================================================== import os -import tempfile import sys import HOMARD import salome @@ -40,19 +39,11 @@ PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') 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(prefix=TEST_NAME) +# ================================== +# Répertoires pour ce test +REP_DATA, DIRCASE, DATA_TUTORIAL = get_dir(PATH_HOMARD, TEST_NAME, DEBUG) # ================================== salome.salome_init() @@ -177,8 +168,8 @@ try : ERROR = homard_exec(salome.myStudy) 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 # diff --git a/src/tests/Test/test_3.py b/src/tests/Test/test_3.py index 3318dd52..21c021bd 100755 --- a/src/tests/Test/test_3.py +++ b/src/tests/Test/test_3.py @@ -21,7 +21,7 @@ Python script for HOMARD Test test_3 """ -__revision__ = "V4.02" +__revision__ = "V4.03" #======================================================================== TEST_NAME = "test_3" @@ -30,7 +30,6 @@ N_BOUCLE = 2 N_ITER_TEST_FILE = 2 #======================================================================== import os -import tempfile import sys import HOMARD import salome @@ -41,19 +40,11 @@ PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') 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(prefix=TEST_NAME) +# ================================== +# Répertoires pour ce test +REP_DATA, DIRCASE, DATA_TUTORIAL = get_dir(PATH_HOMARD, TEST_NAME, DEBUG) # ================================== salome.salome_init() @@ -211,8 +202,8 @@ try : ERROR = homard_exec(salome.myStudy) 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 # diff --git a/src/tests/Test/test_4.py b/src/tests/Test/test_4.py index aae31029..485a29a5 100755 --- a/src/tests/Test/test_4.py +++ b/src/tests/Test/test_4.py @@ -21,7 +21,7 @@ Python script for HOMARD Test test_4 """ -__revision__ = "V3.01" +__revision__ = "V3.02" #======================================================================== TEST_NAME = "test_4" @@ -32,7 +32,6 @@ DY = 400. DZ = 200. #======================================================================== import os -import tempfile import sys import numpy as np import salome @@ -48,19 +47,11 @@ PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') 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(prefix=TEST_NAME) +# ================================== +# Répertoires pour ce test +REP_DATA, DIRCASE, DATA_TUTORIAL = get_dir(PATH_HOMARD, TEST_NAME, DEBUG) # ================================== salome.salome_init() @@ -128,9 +119,9 @@ Python script for GEOM and SMESH try: ficmed = os.path.join(DIRCASE, 'maill.00.med') box_m.ExportMED( ficmed, 0, SMESH.MED_V2_2, 1, None, 1) - except Exception as eee: + except IOError as eee: error = 2 - raise Exception('ExportToMEDX() failed. '+eee.message) + raise Exception('ExportToMEDX() failed. '+str(eee.message)) # break # @@ -218,9 +209,9 @@ Python script for HOMARD hypo_4_1.AddZone('Zone_4_1', 1) hypo_4_1.SetExtraOutput(2) laux = hypo_4_1.GetZones() - nbzone = len(laux)/2 + nbzone = len(laux) // 2 jaux = 0 - for iaux in range(nbzone) : + for _ in range(nbzone) : print(hyponame_1, " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux]) jaux += 2 # Creation of the hypothesis hypo_4_2 @@ -230,9 +221,9 @@ Python script for HOMARD hypo_4_2.AddZone('Zone_4_2', 1) hypo_4_2.SetExtraOutput(2) laux = hypo_4_2.GetZones() - nbzone = len(laux)/2 + nbzone = len(laux) // 2 jaux = 0 - for iaux in range(nbzone) : + for _ in range(nbzone) : print(hyponame_2, " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux]) jaux += 2 # Creation of the hypothesis DISTANCE INVERSE @@ -320,8 +311,8 @@ try : ERROR = geom_smesh_exec(salome.myStudy) if ERROR : raise Exception('Pb in geom_smesh_exec') -except Exception as eee: - raise Exception('Pb in geom_smesh_exec: '+eee.message) +except RuntimeError as eee: + raise Exception('Pb in geom_smesh_exec: '+str(eee.message)) HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') assert HOMARD is not None, "Impossible to load homard engine" @@ -333,8 +324,8 @@ try : ERROR = homard_exec(salome.myStudy) 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 # diff --git a/src/tests/Test/test_5.py b/src/tests/Test/test_5.py index bb3dad19..a7b4b9f8 100755 --- a/src/tests/Test/test_5.py +++ b/src/tests/Test/test_5.py @@ -22,7 +22,7 @@ Python script for HOMARD Specific conditions for Code_Saturne Test test_5 """ -__revision__ = "V2.01" +__revision__ = "V2.02" #======================================================================== TEST_NAME = "test_5" @@ -38,7 +38,6 @@ LG_Z = 160. MESH_NAME = "MESH" #======================================================================== import os -import tempfile import sys import numpy as np import salome @@ -52,19 +51,11 @@ PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') 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(prefix=TEST_NAME) +# ================================== +# Répertoires pour ce test +REP_DATA, DIRCASE, DATA_TUTORIAL = get_dir(PATH_HOMARD, TEST_NAME, DEBUG) # ================================== salome.salome_init() @@ -103,11 +94,11 @@ Python script for MED # coordinates = list() coo_z = -0.5*LG_Z - for kaux in range(nbno_z) : + for _ in range(nbno_z) : coo_y = -0.5*LG_Y - for jaux in range(nbno_y) : + for _ in range(nbno_y) : coo_x = -0.5*LG_X - for iaux in range(nbno_x) : + for _ in range(nbno_x) : coordinates.append(coo_x) coordinates.append(coo_y) coordinates.append(coo_z) @@ -167,9 +158,9 @@ Python script for MED ficmed = os.path.join(DIRCASE, 'maill.00.med') #print "Ecriture du maillage dans le fichier", ficmed meshMEDFile3D.write(ficmed, 2) - except Exception as eee: + except IOError as eee: error = 2 - raise Exception('ExportToMEDX() failed. '+eee.message) + raise Exception('ExportToMEDX() failed. '+str(eee.message)) # break # @@ -308,8 +299,8 @@ try : ERROR = mesh_exec(salome.myStudy) if ERROR : raise Exception('Pb in mesh_exec') -except Exception as eee: - raise Exception('Pb in mesh_exec: '+eee.message) +except RuntimeError as eee: + raise Exception('Pb in mesh_exec: '+str(eee.message)) HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD') assert HOMARD is not None, "Impossible to load homard engine" @@ -321,8 +312,8 @@ try : ERROR = homard_exec(salome.myStudy) 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 # diff --git a/src/tests/Test/test_6.py b/src/tests/Test/test_6.py index 7a1226e0..0182563b 100755 --- a/src/tests/Test/test_6.py +++ b/src/tests/Test/test_6.py @@ -21,7 +21,7 @@ Python script for HOMARD Test test_6 """ -__revision__ = "V1.02" +__revision__ = "V1.03" #======================================================================== TEST_NAME = "test_6" @@ -32,7 +32,6 @@ TAILLE = 10. LG_ARETE = TAILLE*2.5 #======================================================================== import os -import tempfile import sys import HOMARD import salome @@ -43,20 +42,12 @@ PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') 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 test_results from test_util import saveGeometry -# 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(prefix=TEST_NAME) +from test_util import get_dir +from test_util import test_results +# ================================== +# Répertoires pour ce test +REP_DATA, DIRCASE, DATA_TUTORIAL = get_dir(PATH_HOMARD, TEST_NAME, DEBUG) salome.salome_init() import iparameters @@ -299,9 +290,9 @@ while not ERREUR : XAO_FILE = os.path.join(DIRCASE, TEST_NAME+".xao") try : ERREUR = saveGeometry(XAO_FILE, TEST_NAME, "test_salome_"+TEST_NAME) - except Exception, eee: - ERREUR = 2000 - MESSAGE = eee.message + except IOError as eee: + ERREUR = os.error + MESSAGE = str(eee.message) # if ERREUR : MESSAGE += "Pb in saveGeometry" @@ -321,9 +312,9 @@ while not ERREUR : # try: ERREUR, MESSAGE = homard_exec(TEST_NAME, FICMED, XAO_FILE, VERBOSE) - except Exception, eee: - ERREUR = 4000 - MESSAGE = eee.message + except RuntimeError as eee: + ERREUR = os.error + MESSAGE = str(eee.message) # if ERREUR : MESSAGE += "Pb in homard_exec" diff --git a/src/tests/Test/test_util.py b/src/tests/Test/test_util.py index e43156c8..c33f98ea 100755 --- a/src/tests/Test/test_util.py +++ b/src/tests/Test/test_util.py @@ -21,13 +21,41 @@ Python script for HOMARD Utilitaires pour les tests """ -__revision__ = "V3.03" +__revision__ = "V4.01" import os +import tempfile import MEDLoader as ml import shutil #======================================================================== #======================================================================== +def get_dir(path_homard, test_name, debug=False) : + """ +Get directories for the test. +Copyright EDF 2018 + """ +# +# Répertoire des données du test + rep_data = os.path.join(path_homard, "share", "salome", "homardsamples") + rep_data = os.path.normpath(rep_data) +# +# Répertoire des résultats + if debug : + dircase = os.path.join("/tmp", test_name) + if ( os.path.isdir(dircase) ) : + remove_dir(dircase) + os.mkdir(dircase) + else : + dircase = tempfile.mkdtemp(prefix=test_name) +# +# Répertoire des données du tutorial + data_tutorial = os.path.join(path_homard, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") + data_tutorial = os.path.normpath(data_tutorial) +# + return rep_data, dircase, data_tutorial +# +#======================================================================== +#======================================================================== def remove_dir(directory) : """ Empties, then removes a directory. diff --git a/src/tests/Test/tutorial_1.py b/src/tests/Test/tutorial_1.py index 070277b5..25fd3499 100755 --- a/src/tests/Test/tutorial_1.py +++ b/src/tests/Test/tutorial_1.py @@ -21,7 +21,7 @@ Python script for HOMARD Test tutorial_1 associe au tutorial 1 """ -__revision__ = "V4.02" +__revision__ = "V4.03" #======================================================================== TEST_NAME = "tutorial_1" @@ -29,7 +29,6 @@ DEBUG = False N_ITER_TEST_FILE = 3 #======================================================================== import os -import tempfile import sys import HOMARD import salome @@ -40,22 +39,12 @@ PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') 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(prefix=TEST_NAME) -# Repertoire des donnees du tutorial -DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") -DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL) +# ================================== +# Répertoires pour ce test +REP_DATA, DIRCASE, DATA_TUTORIAL = get_dir(PATH_HOMARD, TEST_NAME, DEBUG) +# ================================== sys.path.append(DATA_TUTORIAL) from tutorial_util import gzip_gunzip # ================================== @@ -152,9 +141,9 @@ while not ERREUR : FICMED = os.path.join(DATA_TUTORIAL, TEST_NAME+".00.med") try: ERREUR, MESSAGE = homard_exec("MAILL", FICMED, DEBUG) - except Exception, eee: + except RuntimeError as eee: ERREUR = 2 - MESSAGE = eee.message + MESSAGE = str(eee.message) # if ERREUR : MESSAGE += "Pb in homard_exec" diff --git a/src/tests/Test/tutorial_2.py b/src/tests/Test/tutorial_2.py index f8bfaf34..fa1c3d98 100755 --- a/src/tests/Test/tutorial_2.py +++ b/src/tests/Test/tutorial_2.py @@ -21,7 +21,7 @@ Python script for HOMARD Test tutorial_2 associe au tutorial 2 """ -__revision__ = "V4.02" +__revision__ = "V4.03" #======================================================================== TEST_NAME = "tutorial_2" @@ -29,7 +29,6 @@ DEBUG = False N_ITER_TEST_FILE = 2 #======================================================================== import os -import tempfile import sys import HOMARD import salome @@ -40,22 +39,12 @@ PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') 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(prefix=TEST_NAME) -# Repertoire des donnees du tutorial -DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") -DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL) +# ================================== +# Répertoires pour ce test +REP_DATA, DIRCASE, DATA_TUTORIAL = get_dir(PATH_HOMARD, TEST_NAME, DEBUG) +# ================================== sys.path.append(DATA_TUTORIAL) from tutorial_util import gzip_gunzip # ================================== @@ -168,9 +157,9 @@ while not ERREUR : FICMED = os.path.join(DATA_TUTORIAL, TEST_NAME+".00.med") try: ERREUR, MESSAGE = homard_exec("MZERO", FICMED, DEBUG) - except Exception, eee: + except RuntimeError as eee: ERREUR = 2 - MESSAGE = eee.message + MESSAGE = str(eee.message) # if ERREUR : MESSAGE += "Pb in homard_exec" diff --git a/src/tests/Test/tutorial_3.py b/src/tests/Test/tutorial_3.py index 602ace5f..c207e277 100755 --- a/src/tests/Test/tutorial_3.py +++ b/src/tests/Test/tutorial_3.py @@ -21,7 +21,7 @@ Python script for HOMARD Test tutorial_3 associe au tutorial 3 """ -__revision__ = "V4.02" +__revision__ = "V4.03" #======================================================================== TEST_NAME = "tutorial_3" @@ -29,7 +29,6 @@ DEBUG = False N_ITER_TEST_FILE = 2 #======================================================================== import os -import tempfile import sys import HOMARD import salome @@ -40,22 +39,12 @@ PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') 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(prefix=TEST_NAME) -# Repertoire des donnees du tutorial -DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") -DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL) +# ================================== +# Répertoires pour ce test +REP_DATA, DIRCASE, DATA_TUTORIAL = get_dir(PATH_HOMARD, TEST_NAME, DEBUG) +# ================================== sys.path.append(DATA_TUTORIAL) from tutorial_util import gzip_gunzip # ================================== @@ -196,9 +185,9 @@ while not ERREUR : FICMED = os.path.join(DATA_TUTORIAL, TEST_NAME+".00.med") try: ERREUR, MESSAGE = homard_exec("G_0", FICMED, DEBUG) - except Exception, eee: + except RuntimeError as eee: ERREUR = 2 - MESSAGE = eee.message + MESSAGE = str(eee.message) # if ERREUR : MESSAGE += "Pb in homard_exec" diff --git a/src/tests/Test/tutorial_4.py b/src/tests/Test/tutorial_4.py index 9e05df94..2bbdaf9a 100755 --- a/src/tests/Test/tutorial_4.py +++ b/src/tests/Test/tutorial_4.py @@ -21,7 +21,7 @@ Python script for HOMARD Test tutorial_4 associe au tutorial 4 """ -__revision__ = "V5.01" +__revision__ = "V5.02" #======================================================================== TEST_NAME = "tutorial_4" @@ -29,7 +29,6 @@ DEBUG = False N_ITER_TEST_FILE = 3 #======================================================================== import os -import tempfile import sys import HOMARD import salome @@ -40,22 +39,12 @@ PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') 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(prefix=TEST_NAME) -# Repertoire des donnees du tutorial -DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") -DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL) +# ================================== +# Répertoires pour ce test +REP_DATA, DIRCASE, DATA_TUTORIAL = get_dir(PATH_HOMARD, TEST_NAME, DEBUG) +# ================================== sys.path.append(DATA_TUTORIAL) from tutorial_util import gzip_gunzip # ================================== @@ -179,9 +168,9 @@ while not ERREUR : XAO_FILE = os.path.join(DATA_TUTORIAL, TEST_NAME+".xao") try: ERREUR, MESSAGE = homard_exec("PIQUAGE", FICMED, XAO_FILE, DEBUG) - except Exception, eee: + except RuntimeError as eee: ERREUR = 2 - MESSAGE = eee.message + MESSAGE = str(eee.message) # if ERREUR : MESSAGE += "Pb in homard_exec" diff --git a/src/tests/Test/tutorial_5.py b/src/tests/Test/tutorial_5.py index afdad37e..1cb675e8 100755 --- a/src/tests/Test/tutorial_5.py +++ b/src/tests/Test/tutorial_5.py @@ -21,7 +21,7 @@ Python script for HOMARD Test tutorial_5 associe au tutorial 5 """ -__revision__ = "V4.02" +__revision__ = "V4.03" #======================================================================== TEST_NAME = "tutorial_5" @@ -29,7 +29,6 @@ DEBUG = False N_ITER_TEST_FILE = 2 #======================================================================== import os -import tempfile import sys import HOMARD import salome @@ -40,22 +39,12 @@ PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') 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(prefix=TEST_NAME) -# Repertoire des donnees du tutorial -DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") -DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL) +# ================================== +# Répertoires pour ce test +REP_DATA, DIRCASE, DATA_TUTORIAL = get_dir(PATH_HOMARD, TEST_NAME, DEBUG) +# ================================== sys.path.append(DATA_TUTORIAL) from tutorial_util import gzip_gunzip # ================================== @@ -169,9 +158,9 @@ while not ERREUR : FICFRMED = os.path.join(DATA_TUTORIAL, TEST_NAME+".fr.med") try: ERREUR, MESSAGE = homard_exec("COEUR_2D", FICMED, "MAIL_EXT", FICFRMED, DEBUG) - except Exception, eee: + except RuntimeError as eee: ERREUR = 2 - MESSAGE = eee.message + MESSAGE = str(eee.message) # if ERREUR : MESSAGE += "Pb in homard_exec" diff --git a/src/tests/Test/tutorial_6.py b/src/tests/Test/tutorial_6.py index 849998df..b62473cd 100755 --- a/src/tests/Test/tutorial_6.py +++ b/src/tests/Test/tutorial_6.py @@ -21,7 +21,7 @@ Python script for HOMARD Test tutorial_6 associe au tutorial 6 """ -__revision__ = "V4.02" +__revision__ = "V4.03" #======================================================================== TEST_NAME = "tutorial_6" @@ -29,7 +29,6 @@ DEBUG = False N_ITER_TEST_FILE = 3 #======================================================================== import os -import tempfile import sys import HOMARD import salome @@ -40,22 +39,12 @@ PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') 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(prefix=TEST_NAME) -# Repertoire des donnees du tutorial -DATA_TUTORIAL = os.path.join(PATH_HOMARD, "share", "doc", "salome", "gui", "HOMARD", "fr", "_downloads") -DATA_TUTORIAL = os.path.normpath(DATA_TUTORIAL) +# ================================== +# Répertoires pour ce test +REP_DATA, DIRCASE, DATA_TUTORIAL = get_dir(PATH_HOMARD, TEST_NAME, DEBUG) +# ================================== sys.path.append(DATA_TUTORIAL) from tutorial_util import gzip_gunzip # ================================== @@ -193,9 +182,9 @@ while not ERREUR : FICFRMED = os.path.join(DATA_TUTORIAL, TEST_NAME+".fr.med") try: ERREUR, MESSAGE = homard_exec("PIQUAGE", FICMED, "COURBES", FICFRMED, DEBUG) - except Exception, eee: + except RuntimeError as eee: ERREUR = 2 - MESSAGE = eee.message + MESSAGE = str(eee.message) # if ERREUR : MESSAGE += "Pb in homard_exec"