Salome HOME
- Launcher can now load and save its jobs list
[modules/kernel.git] / src / Launcher / Launcher_Job_Command.cxx
index 313a0b02655c4e66846effa1c43d940c1511c6b3..9b291ec373142cfb665674a25ce2a03720a96ddd 100644 (file)
@@ -1,4 +1,4 @@
-//  Copyright (C) 2009 CEA/DEN, EDF R&D
+//  Copyright (C) 2009-2010  CEA/DEN, EDF R&D
 //
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of the GNU Lesser General Public
 //
 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
-// Author: AndrĂ© RIBES - EDF R&D
 
+// Author: AndrĂ© RIBES - EDF R&D
+//
 #include "Launcher_Job_Command.hxx"
 
-Launcher::Job_Command::Job_Command() {}
+Launcher::Job_Command::Job_Command() {_job_type = "command";}
 
 Launcher::Job_Command::~Job_Command() {}
 
@@ -29,7 +30,7 @@ Launcher::Job_Command::update_job()
 {
 #ifdef WITH_LIBBATCH
   Batch::Parametre params = common_job_params();
-  params[EXECUTABLE] = buildCommandScript(params, _launch_date);
+  params[Batch::EXECUTABLE] = buildCommandScript(params, _launch_date);
   _batch_job->setParametre(params);
 #endif
 }
@@ -39,19 +40,19 @@ std::string
 Launcher::Job_Command::buildCommandScript(Batch::Parametre params, std::string launch_date)
 {
   // parameters
-  std::string work_directory = params[WORKDIR].str();
+  std::string work_directory = params[Batch::WORKDIR].str();
 
   // File name
-  std::string::size_type p1 = _job_file.find_last_of("/");
-  
   std::string launch_date_port_file = launch_date;
   std::string launch_script = "/tmp/runCommand_" + _job_file_name + "_" + launch_date + ".sh";
   std::ofstream launch_script_stream;
   launch_script_stream.open(launch_script.c_str(), std::ofstream::out);
    
   // Script
-  launch_script_stream << "#! /bin/sh -f" << std::endl;
+  launch_script_stream << "#! /bin/bash -f" << std::endl;
   launch_script_stream << "cd " << work_directory << std::endl;
+  launch_script_stream << "export PYTHONPATH=" << work_directory << ":$PYTHONPATH" << std::endl;
+  launch_script_stream << "export PATH=" << work_directory << ":$PATH" << std::endl;
   if (_env_file != "")
   {
     std::string::size_type last = _env_file.find_last_of("/");