Salome HOME
Merge branch 'omu/multijob'
[tools/ydefx.git] / src / pyexample / multijob / jobstudy.py
1 import pydefx.configuration
2 import pydefx.salome_proxy
3 import os
4 import time
5
6 def _exec(n):
7   # get the job parameters
8   salome_parameters = pydefx.configuration.loadJobConfig()
9
10   launcher = pydefx.salome_proxy.getLauncher() # CORBA or not CORBA
11
12   # have a different working directory for each computation
13   resource = salome_parameters.resource_required.name
14   default_wd = pydefx.configuration.defaultWorkingDir(resource)
15   new_wd = os.path.join(default_wd, "myjob_"+str(n))
16   salome_parameters.work_directory = new_wd
17
18   # create and launch the job
19   job_id = launcher.createJob(salome_parameters)
20   launcher.launchJob(job_id)
21
22   # wait for the end of the job
23   jobState = launcher.getJobState(job_id)
24   while jobState != "FINISHED" and jobState != "FAILED" :
25     time.sleep(5)
26     jobState = launcher.getJobState(job_id)
27   return jobState