X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=doc%2Ffiles%2Ftutorial_util.py;h=57149f4a41020b9479b62d48b05858ba5b963f9b;hb=8d7d01c43ae1939e2d7834e4b1a3104239466b82;hp=b409c7a3332d949f37dcd1e5711c8b8459e41bf2;hpb=bb4659c87071220a19ba3564eb8eece0b06592b1;p=modules%2Fhomard.git diff --git a/doc/files/tutorial_util.py b/doc/files/tutorial_util.py index b409c7a3..57149f4a 100755 --- a/doc/files/tutorial_util.py +++ b/doc/files/tutorial_util.py @@ -1,5 +1,5 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2011-2014 CEA/DEN, EDF R&D +# -*- coding: utf-8 -*- +# Copyright (C) 2011-2016 CEA/DEN, EDF R&D # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -19,25 +19,26 @@ # """ Python script for HOMARD -Copyright EDF-R&D 2014 +Copyright EDF 2014, 2018 """ -__revision__ = "V1.1" +__revision__ = "V2.02" import os import sys -pathHomard = os.getenv('HOMARD_ROOT_DIR') -# Repertoire des tests -Rep_Test = os.path.join(pathHomard, "share", "salome", "resources", "homard") -Rep_Test = os.path.normpath(Rep_Test) -sys.path.append(Rep_Test) +PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR') +# Repertoire des scripts utilitaires +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 -#======================================================================== -#======================================================================== +# +#========================= Debut de la fonction ================================== +# def gzip_gunzip(data_dir, num_tuto, option) : """ -Compression/Uncompression of the med files of a directory such as tutorial_x.nn.med +Compression/Uncompression of the med(or xao) files of a directory such as tutorial_x.nn.med (or tutorial_x.nn.xao) data_dir: directory num_tuto: number of the tutorial option : 1: compression, -1: uncompression @@ -46,14 +47,14 @@ Copyright EDF-R&D 2014 # ficloc_basis = "tutorial_%d" % num_tuto # - ok = True + erreur = 0 num = -1 # # Uncompression # if ( option == -1 ) : # - while ok : + while not erreur : num += 1 ficloc = ficloc_basis + ".%02d.med" % num nomfic = os.path.join(data_dir, ficloc) @@ -63,22 +64,23 @@ Copyright EDF-R&D 2014 if os.path.isfile(nomfic) : os.system("gunzip "+nomfic) else : - ok = False + erreur = 1 break # - ficloc = ficloc_basis + ".fr.med" - nomfic = os.path.join(data_dir, ficloc) - if not os.path.isfile(nomfic) : - ficloc += ".gz" + for suffixe in ( "xao", "fr.med" ) : + ficloc = ficloc_basis + "." + suffixe nomfic = os.path.join(data_dir, ficloc) - if os.path.isfile(nomfic) : - os.system("gunzip "+nomfic) + if not os.path.isfile(nomfic) : + ficloc += ".gz" + nomfic = os.path.join(data_dir, ficloc) + if os.path.isfile(nomfic) : + os.system("gunzip "+nomfic) # # Compression # elif ( option == 1 ) : # - while ok : + while not erreur : num += 1 ficloc = ficloc_basis + ".%02d.med.gz" % num nomfic = os.path.join(data_dir, ficloc) @@ -88,21 +90,24 @@ Copyright EDF-R&D 2014 if os.path.isfile(nomfic) : os.system("gzip "+nomfic) else : - ok = False + erreur = 2 break # - ficloc = ficloc_basis + ".fr.med.gz" - nomfic = os.path.join(data_dir, ficloc) - if not os.path.isfile(nomfic) : - ficloc = ficloc_basis + ".fr.med" + for suffixe in ( "xao", "fr.med" ) : + ficloc = ficloc_basis + "." + suffixe + ".gz" nomfic = os.path.join(data_dir, ficloc) - if os.path.isfile(nomfic) : - os.system("gzip "+nomfic) + if not os.path.isfile(nomfic) : + ficloc = ficloc_basis + ".fr.med" + nomfic = os.path.join(data_dir, ficloc) + if os.path.isfile(nomfic) : + os.system("gzip "+nomfic) # return # -#======================================================================== -#======================================================================== +#========================== Fin de la fonction ================================== +# +#========================= Debut de la fonction ================================== +# def creation_dircase(num_tuto) : """ Creation of a directory for the results of tutorial_x @@ -110,7 +115,7 @@ num_tuto: number of the tutorial Copyright EDF-R&D 2014 """ # - if os.environ.has_key("LOGNAME") : + if "LOGNAME" in os.environ : user = os.environ ["LOGNAME"] else : user = "anonymous" @@ -124,6 +129,6 @@ Copyright EDF-R&D 2014 os.mkdir (dircase) # return dircase -#======================================================================== -#======================================================================== +# +#========================== Fin de la fonction ================================== #