1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2011-2014 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-R&D 2014
29 pathHomard = os.getenv('HOMARD_ROOT_DIR')
30 # Repertoire des tests
31 Rep_Test = os.path.join(pathHomard, "share", "salome", "resources", "homard")
32 Rep_Test = os.path.normpath(Rep_Test)
33 sys.path.append(Rep_Test)
34 from test_util import remove_dir
36 #========================================================================
37 #========================================================================
38 def gzip_gunzip(data_dir, num_tuto, option) :
40 Compression/Uncompression of the med files of a directory such as tutorial_x.nn.med
42 num_tuto: number of the tutorial
43 option : 1: compression, -1: uncompression
44 Copyright EDF-R&D 2014
47 ficloc_basis = "tutorial_%d" % num_tuto
58 ficloc = ficloc_basis + ".%02d.med" % num
59 nomfic = os.path.join(data_dir, ficloc)
60 if not os.path.isfile(nomfic) :
62 nomfic = os.path.join(data_dir, ficloc)
63 if os.path.isfile(nomfic) :
64 os.system("gunzip "+nomfic)
69 ficloc = ficloc_basis + ".fr.med"
70 nomfic = os.path.join(data_dir, ficloc)
71 if not os.path.isfile(nomfic) :
73 nomfic = os.path.join(data_dir, ficloc)
74 if os.path.isfile(nomfic) :
75 os.system("gunzip "+nomfic)
79 elif ( option == 1 ) :
83 ficloc = ficloc_basis + ".%02d.med.gz" % num
84 nomfic = os.path.join(data_dir, ficloc)
85 if not os.path.isfile(nomfic) :
86 ficloc = ficloc_basis + ".%02d.med" % num
87 nomfic = os.path.join(data_dir, ficloc)
88 if os.path.isfile(nomfic) :
89 os.system("gzip "+nomfic)
94 ficloc = ficloc_basis + ".fr.med.gz"
95 nomfic = os.path.join(data_dir, ficloc)
96 if not os.path.isfile(nomfic) :
97 ficloc = ficloc_basis + ".fr.med"
98 nomfic = os.path.join(data_dir, ficloc)
99 if os.path.isfile(nomfic) :
100 os.system("gzip "+nomfic)
104 #========================================================================
105 #========================================================================
106 def creation_dircase(num_tuto) :
108 Creation of a directory for the results of tutorial_x
109 num_tuto: number of the tutorial
110 Copyright EDF-R&D 2014
113 if os.environ.has_key("LOGNAME") :
114 user = os.environ ["LOGNAME"]
117 dircase = os.path.join( os.sep, "tmp", "HOMARD_"+user)
118 if not os.path.isdir(dircase) :
120 dirtuto_basis = "tutorial_%d" % num_tuto
121 dircase = os.path.join( dircase, dirtuto_basis )
122 if os.path.isdir(dircase) :
127 #========================================================================
128 #========================================================================