Salome HOME
Merge class BatchManager_eClient into class BatchManager
[tools/libbatch.git] / src / Python / Test / Test_Python_Local_SH.py
index a6dae7da9017d29f7b83c6aee5c34baddc9af9df..d32732439235441de04cf804bfb17745881c7d1b 100644 (file)
@@ -42,13 +42,13 @@ def work():
     job = Job()
     # ... and its parameters ...
     p = {}
-    p[EXECUTABLE] = './copied-' + config.EXEC_TEST_NAME
+    p[EXECUTABLE] = config.EXEC_TEST_FULL_PATH
     p[ARGUMENTS]  = ["copied-seta.sh", "copied-setb.sh", "orig-result.txt"];
     p[NAME] = 'Test_Python_Local_SH'
     p[WORKDIR] = config.TEST_LOCAL_SH_WORK_DIR
-    p[INFILE] = [('seta.sh', 'copied-seta.sh'), ('setb.sh', 'copied-setb.sh'),
-                   (config.EXEC_TEST_FULL_PATH, 'copied-' + config.EXEC_TEST_NAME)]
-    p[OUTFILE] = [('result.txt', 'orig-result.txt')]
+    p[INFILE] = [('seta.sh', p[WORKDIR] + '/copied-seta.sh'),
+                 ('setb.sh', p[WORKDIR] + '/copied-setb.sh')]
+    p[OUTFILE] = [('result.txt', p[WORKDIR] + '/orig-result.txt')]
     job.setParametre(p)
     # ... and its environment
     e = {}
@@ -58,8 +58,8 @@ def work():
     # Get the catalog
     c = BatchManagerCatalog.getInstance()
 
-    # Create a BatchManager of type Local_SSH on localhost
-    bm = c('SH')('localhost')
+    # Create a BatchManager of type Local_SH on localhost
+    bm = c('LOCAL')('localhost', '', SH)
 
     # Submit the job to the BatchManager
     jobid = bm.submitJob(job)
@@ -71,15 +71,25 @@ def work():
     # Wait for the end of the job
     state = bm.waitForJobEnd(jobid, config.TEST_LOCAL_SH_TIMEOUT);
 
+
+    if state == FINISHED:
+        print "Job", jobid, "is done"
+        bm.importOutputFiles(job, "resultdir/seconddirname")
+    elif state == FAILED:
+        print "Job", jobid, " finished in error"
+        bm.importOutputFiles(job, "resultdir/seconddirname")
+        return 1
+    else:
+        print "Timeout while executing job"
+        return 1
+
     if state != FINISHED and state != FAILED:
         print "Error: Job not finished after timeout"
         return 1;
 
-    print "Job", jobid, "is done"
-
     # test the result file
     exp = "c = 12"
-    f = open('result.txt')
+    f = open('resultdir/seconddirname/result.txt')
     res = f.read().strip()
     print "result found : %s, expected : %s" % (res, exp)