1 # Copyright (C) 2011-2013 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
20 # Author(s): Guillaume Boulant (23/03/2011)
23 # TODO: put all this stuff in the unitests package
28 This returns the root directory where the module SPADDER is
29 installed. All test files are looked up from this location.
31 return os.environ['SMESH_ROOT_DIR']
35 This function gives the absolute path to the SMESH directory
36 containing the data files for the padder plugin test (realistic
39 datadir = os.path.join(getRootDir(),"share/salome/resources/smesh/padderdata")
42 def getTestPadderDataDir():
44 This function gives the absolute path to the PADDER directory
45 containing the data files for the padder plugin test. WARNING:
46 this directory is a directory of the external program SpherePadder
47 that is wrapped by the padder plugin. We use the shell variable
48 PADDERHOME (defined by the SALOME environment) to localize this
51 PADDERHOME = os.environ['PADDERHOME']
52 datadir = os.path.join(PADDERHOME,"tests")
55 import MESHJOB # to get the enum constant values
56 from MESHJOB import MeshJobParameter, MeshJobParameterList
58 DEFAULT_CONCRETE_FILENAME=os.path.join(getTestDataDir(),'concrete.med')
59 DEFAULT_STEELBAR_LISTFILENAME=[
60 os.path.join(getTestDataDir(),'ferraill.med')
63 def getMeshJobParameterList(concrete_filename=DEFAULT_CONCRETE_FILENAME,
64 steelbar_listfilename=DEFAULT_STEELBAR_LISTFILENAME):
66 This helper function creates a complete set of parameters (a
67 MeshJobParameterList) for a simple test case, i.e. a case with a
68 concrete filename and a single steelbar filename.
70 # Note that a CORBA sequence (MeshJobParameterList) is mapped on a
71 # simple list in python
72 meshJobParameterList = []
73 # We can add some parameters
74 param = MeshJobParameter(
75 file_name = concrete_filename,
76 file_type = MESHJOB.MED_CONCRETE,
77 group_name = "concrete")
78 meshJobParameterList.append(param)
80 for steelbar_filename in steelbar_listfilename:
81 param = MeshJobParameter(
82 file_name = steelbar_filename,
83 file_type = MESHJOB.MED_STEELBAR,
84 group_name = "steelbar")
85 meshJobParameterList.append(param)
87 return meshJobParameterList
90 def getSpadderCatalogFilename():
91 filename=os.path.join(getRootDir(),"share/salome/resources/smesh/SPADDERCatalog.xml")
94 def loadSpadderCatalog():
97 obj = salome.naming_service.Resolve('Kernel/ModulCatalog')
98 import SALOME_ModuleCatalog
99 catalog = obj._narrow(SALOME_ModuleCatalog.ModuleCatalog)
101 raise RuntimeError, "Can't accesss module catalog"
103 filename = getSpadderCatalogFilename()
104 catalog.ImportXmlCatalogFile(filename)
106 from salome.kernel import services
107 print "The list of SALOME components is now:"
108 print services.getComponentList()