1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2011-2020 CEA/DEN, EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 Python script for HOMARD
22 Copyright EDF 2014, 2018
24 __revision__ = "V2.02"
29 PATH_HOMARD = os.getenv('HOMARD_ROOT_DIR')
30 # Repertoire des scripts utilitaires
31 REP_PYTHON = os.path.join(PATH_HOMARD, "bin", "salome", "test", "HOMARD")
32 REP_PYTHON = os.path.normpath(REP_PYTHON)
33 sys.path.append(REP_PYTHON)
34 from test_util import remove_dir
37 #========================= Debut de la fonction ==================================
39 def gzip_gunzip(data_dir, num_tuto, option) :
41 Compression/Uncompression of the med(or xao) files of a directory such as tutorial_x.nn.med (or tutorial_x.nn.xao)
43 num_tuto: number of the tutorial
44 option : 1: compression, -1: uncompression
45 Copyright EDF-R&D 2014
48 ficloc_basis = "tutorial_%d" % num_tuto
59 ficloc = ficloc_basis + ".%02d.med" % num
60 nomfic = os.path.join(data_dir, ficloc)
61 if not os.path.isfile(nomfic) :
63 nomfic = os.path.join(data_dir, ficloc)
64 if os.path.isfile(nomfic) :
65 os.system("gunzip "+nomfic)
70 for suffixe in ( "xao", "fr.med" ) :
71 ficloc = ficloc_basis + "." + suffixe
72 nomfic = os.path.join(data_dir, ficloc)
73 if not os.path.isfile(nomfic) :
75 nomfic = os.path.join(data_dir, ficloc)
76 if os.path.isfile(nomfic) :
77 os.system("gunzip "+nomfic)
81 elif ( option == 1 ) :
85 ficloc = ficloc_basis + ".%02d.med.gz" % num
86 nomfic = os.path.join(data_dir, ficloc)
87 if not os.path.isfile(nomfic) :
88 ficloc = ficloc_basis + ".%02d.med" % num
89 nomfic = os.path.join(data_dir, ficloc)
90 if os.path.isfile(nomfic) :
91 os.system("gzip "+nomfic)
96 for suffixe in ( "xao", "fr.med" ) :
97 ficloc = ficloc_basis + "." + suffixe + ".gz"
98 nomfic = os.path.join(data_dir, ficloc)
99 if not os.path.isfile(nomfic) :
100 ficloc = ficloc_basis + ".fr.med"
101 nomfic = os.path.join(data_dir, ficloc)
102 if os.path.isfile(nomfic) :
103 os.system("gzip "+nomfic)
107 #========================== Fin de la fonction ==================================
109 #========================= Debut de la fonction ==================================
111 def creation_dircase(num_tuto) :
113 Creation of a directory for the results of tutorial_x
114 num_tuto: number of the tutorial
115 Copyright EDF-R&D 2014
118 if "LOGNAME" in os.environ :
119 user = os.environ ["LOGNAME"]
122 dircase = os.path.join( os.sep, "tmp", "HOMARD_"+user)
123 if not os.path.isdir(dircase) :
125 dirtuto_basis = "tutorial_%d" % num_tuto
126 dircase = os.path.join( dircase, dirtuto_basis )
127 if os.path.isdir(dircase) :
133 #========================== Fin de la fonction ==================================