1 # Copyright (C) 2011-2012 EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 # Author(s): Guillaume Boulant (23/03/2011)
22 # TODO: put all this stuff in the unitests package
27 This returns the root directory where the module SPADDER is
28 installed. All test files are looked up from this location.
30 return os.environ['SMESH_ROOT_DIR']
34 This function gives the absolute path to the SMESH directory
35 containing the data files for the padder plugin test (realistic
38 datadir = os.path.join(getRootDir(),"share/salome/resources/smesh/padderdata")
41 def getTestPadderDataDir():
43 This function gives the absolute path to the PADDER directory
44 containing the data files for the padder plugin test. WARNING:
45 this directory is a directory of the external program SpherePadder
46 that is wrapped by the padder plugin. We use the shell variable
47 PADDERHOME (defined by the SALOME environment) to localize this
50 PADDERHOME = os.environ['PADDERHOME']
51 datadir = os.path.join(PADDERHOME,"tests")
54 import MESHJOB # to get the enum constant values
55 from MESHJOB import MeshJobParameter, MeshJobParameterList
57 DEFAULT_CONCRETE_FILENAME=os.path.join(getTestDataDir(),'concrete.med')
58 DEFAULT_STEELBAR_LISTFILENAME=[
59 os.path.join(getTestDataDir(),'ferraill.med')
62 def getMeshJobParameterList(concrete_filename=DEFAULT_CONCRETE_FILENAME,
63 steelbar_listfilename=DEFAULT_STEELBAR_LISTFILENAME):
65 This helper function creates a complete set of parameters (a
66 MeshJobParameterList) for a simple test case, i.e. a case with a
67 concrete filename and a single steelbar filename.
69 # Note that a CORBA sequence (MeshJobParameterList) is mapped on a
70 # simple list in python
71 meshJobParameterList = []
72 # We can add some parameters
73 param = MeshJobParameter(
74 file_name = concrete_filename,
75 file_type = MESHJOB.MED_CONCRETE,
76 group_name = "concrete")
77 meshJobParameterList.append(param)
79 for steelbar_filename in steelbar_listfilename:
80 param = MeshJobParameter(
81 file_name = steelbar_filename,
82 file_type = MESHJOB.MED_STEELBAR,
83 group_name = "steelbar")
84 meshJobParameterList.append(param)
86 return meshJobParameterList
89 def getSpadderCatalogFilename():
90 filename=os.path.join(getRootDir(),"share/salome/resources/smesh/SPADDERCatalog.xml")
93 def loadSpadderCatalog():
96 obj = salome.naming_service.Resolve('Kernel/ModulCatalog')
97 import SALOME_ModuleCatalog
98 catalog = obj._narrow(SALOME_ModuleCatalog.ModuleCatalog)
100 raise RuntimeError, "Can't accesss module catalog"
102 filename = getSpadderCatalogFilename()
103 catalog.ImportXmlCatalogFile(filename)
105 from salome.kernel import services
106 print "The list of SALOME components is now:"
107 print services.getComponentList()