1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2011 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.
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
20 # Author(s): Guillaume Boulant (23/03/2011)
23 # This script illustrates the standard use case of the component
24 # MeshJobManager from within a SALOME script.
28 # Preparing the configuration parameters
31 from salome.smesh import spadder
32 pathpadderexe=os.path.join(spadder.getTestDataDir(),"padder.exe")
33 pathpadderenv=os.path.join(spadder.getTestDataDir(),"envPadder.sh")
34 file_concrete=os.path.join(spadder.getTestDataDir(),"concrete.med")
35 file_steelbar=os.path.join(spadder.getTestDataDir(),"ferraill.med")
41 # Setup the configuration in the component. When first have to load
42 # the catalog of SPADDER components, then load the component
43 # MeshJobManager, and finally configure this component.
45 from salome.smesh import spadder
46 spadder.loadSpadderCatalog()
49 component = salome.lcc.FindOrLoadComponent("FactoryServer","MeshJobManager")
50 config = MESHJOB.ConfigParameter(resname="localhost",
51 binpath=pathpadderexe,
52 envpath=pathpadderenv)
53 component.configure("localhost",config)
56 # Prepare the job parameters and initialize the job
58 meshJobParameterList = []
59 param = MESHJOB.MeshJobParameter(file_name=file_concrete,
60 file_type=MESHJOB.MED_CONCRETE,
61 group_name="concrete")
62 meshJobParameterList.append(param)
64 param = MESHJOB.MeshJobParameter(file_name=file_steelbar,
65 file_type=MESHJOB.MED_STEELBAR,
66 group_name="steelbar")
67 meshJobParameterList.append(param)
68 jobid = component.initialize(meshJobParameterList, "localhost")
71 # Start the execution of the job identified by its job id.
73 component.start(jobid)
77 # This part illustrates how you can follow the execution of the job.
79 run_states = ["CREATED", "IN_PROCESS", "QUEUED", "RUNNING", "PAUSED"];
80 end_states = ["FINISHED", "ERROR"]
81 all_states = run_states+end_states;
87 state = component.getState(jobid)
88 print "MeshJobManager ["+str(nbiter)+"] : state = "+str(state)
89 if state not in run_states:
94 if state not in end_states:
95 print "ERR: jobid = "+str(jobid)+" ended abnormally with state="+str(state)
97 print "OK: jobid = "+str(jobid)+" ended with state="+str(state)
98 meshJobResults = component.finalize(jobid)
100 print "You will find the results files in the directory:\n%s"%meshJobResults.results_dirname