Salome HOME
Merge branch 'omu/SalomeLauncher'
[modules/kernel.git] / src / Launcher / Launcher.cxx
index 404a2b8d0bc301d4bf2a53b5471b622cd458ab6d..e41234d255f80ba0f2c7ee74ea3f9b3f1430f5c7 100644 (file)
@@ -286,6 +286,45 @@ Launcher_cpp::getJobDumpState(int job_id, std::string directory)
   return rtn;
 }
 
+//=============================================================================
+/*!
+ * Get one file from the working directory - the result directory can be changed
+ */
+//=============================================================================
+bool
+Launcher_cpp::getJobWorkFile(int job_id,
+                             std::string work_file,
+                             std::string directory)
+{
+  bool rtn;
+  LAUNCHER_MESSAGE("Get working file " << work_file);
+
+  // Check if job exist
+  std::map<int, Launcher::Job *>::const_iterator it_job = _launcher_job_map.find(job_id);
+  if (it_job == _launcher_job_map.end())
+  {
+    LAUNCHER_INFOS("Cannot find the job, is it created ? job number: " << job_id);
+    throw LauncherException("Cannot find the job, is it created ?");
+  }
+
+  Launcher::Job * job = it_job->second;
+  std::string resource_name = job->getResourceDefinition().Name;
+  try
+  {
+    if (directory != "")
+      rtn = _batchmap[job_id]->importWorkFile(*(job->getBatchJob()), work_file, directory);
+    else
+      rtn = _batchmap[job_id]->importWorkFile(*(job->getBatchJob()), work_file, job->getResultDirectory());
+  }
+  catch(const Batch::GenericException &ex)
+  {
+    LAUNCHER_INFOS("getJobWorkFile is maybe incomplete, exception: " << ex.message);
+    throw LauncherException(ex.message.c_str());
+  }
+  LAUNCHER_MESSAGE("getJobWorkFile ended");
+  return rtn;
+}
+
 //=============================================================================
 /*!
  * Remove the job - into the Launcher and its batch manager
@@ -545,6 +584,14 @@ Launcher_cpp::getJobDumpState(int job_id, std::string directory)
                           "(libBatch was not present at compilation time)");
 }
 
+bool
+Launcher_cpp::getJobWorkFile(int job_id, std::string work_file, std::string directory)
+{
+  LAUNCHER_INFOS("Launcher compiled without LIBBATCH - cannot get job dump state!!!");
+  throw LauncherException("Method Launcher_cpp::getJobWorkFile is not available "
+                          "(libBatch was not present at compilation time)");
+}
+
 void
 Launcher_cpp::removeJob(int job_id)
 {