1 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
28 # Import libBatch library
29 from libBatch_Swig import *
32 print "*******************************************************************************************"
33 print "This script tests the local batch submission based on SH. No specific configuration is"
34 print "needed for this test."
35 print "*******************************************************************************************"
37 # eventually remove any previous result
38 if (os.path.exists('result.txt')):
39 os.remove('result.txt')
43 # ... and its parameters ...
45 p['EXECUTABLE'] = './copied-test-script.sh'
46 p['NAME'] = 'Test_Local_SH'
48 p['INFILE'] = [('seta.sh', 'copied-seta.sh'), ('setb.sh', 'copied-setb.sh'),
49 ('test-script.sh', 'copied-test-script.sh')]
50 p['OUTFILE'] = [('result.txt', 'orig-result.txt')]
52 # ... and its environment
54 job.setEnvironnement(e)
58 c = BatchManagerCatalog.getInstance()
60 # Create a BatchManager of type Local_SSH on localhost
61 bm = c('SH')('localhost')
63 # Submit the job to the BatchManager
64 jobid = bm.submitJob(job)
70 # Wait for the end of the job
73 while state != 'Done' and i<20:
76 jinfo = jobid.queryJob()
78 state = jinfo.getParametre()['STATE']
81 print "State is", state
84 print "Error: Job not finished after timeout"
87 print "Job", jobid, "is done"
89 # wait for 2 more seconds for the copy of output files and the cleanup
90 # (there's no cleaner way to do that yet)
93 # test the result file
95 f = open('result.txt')
96 res = f.read().strip()
97 print "result found : %s, expected : %s" % (res, exp)
104 if __name__ == "__main__":