]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
- Adding new type of Job: python_salome new_launcher_alpha_091125
authorribes <ribes>
Wed, 25 Nov 2009 14:49:06 +0000 (14:49 +0000)
committerribes <ribes>
Wed, 25 Nov 2009 14:49:06 +0000 (14:49 +0000)
- Using USER env variable if UserName is not defined in the
resource description

14 files changed:
idl/SALOME_ContainerManager.idl
src/Launcher/Launcher.cxx
src/Launcher/Launcher_Job.cxx
src/Launcher/Launcher_Job.hxx
src/Launcher/Launcher_Job_Command.cxx
src/Launcher/Launcher_Job_Command.hxx
src/Launcher/Launcher_Job_PythonSALOME.cxx [new file with mode: 0644]
src/Launcher/Launcher_Job_PythonSALOME.hxx [new file with mode: 0644]
src/Launcher/Launcher_Job_SALOME.cxx [new file with mode: 0644]
src/Launcher/Launcher_Job_SALOME.hxx [new file with mode: 0644]
src/Launcher/Launcher_Job_YACSFile.cxx
src/Launcher/Launcher_Job_YACSFile.hxx
src/Launcher/Makefile.am
src/Launcher/SALOME_Launcher.cxx

index f886b8c620942d35afa3c774e92a832ad24a9f6c..ebd2c47f9b87e5c6f829f1d658a42893fdee0f3f 100644 (file)
@@ -116,16 +116,11 @@ exception NotFound {};
 
 struct JobParameters
 {
-  //! Job Type - Could be equal to "command" or "yacs_file"
+  //! Job Type - Could be equal to "command" or "yacs_file" or "python_salome"
   string job_type;
 
-  //! YACS file
-  string yacs_file;
-
-  //! Command
-  string command;
-
   // Common values
+  string job_file;
   string env_file; 
   FilesList in_files;
   FilesList out_files;
index fffee68cf9b1e60530a9a4a9f5720f51a4896d26..c77c680b2473e568afb452019818736ff797812d 100644 (file)
@@ -309,7 +309,8 @@ Launcher_cpp::createJobWithFile(const std::string xmlExecuteFile,
   ParserLauncherType job_params = ParseXmlFile(xmlExecuteFile);
 
   // Creating a new job
-  Launcher::Job_Command * new_job = new Launcher::Job_Command(job_params.Command);
+  Launcher::Job_Command * new_job = new Launcher::Job_Command();
+  new_job->setJobFile(job_params.Command);
   new_job->setLocalDirectory(job_params.RefDirectory);
   new_job->setWorkDirectory(job_params.MachinesList[clusterName].WorkDirectory);
   new_job->setEnvFile(job_params.MachinesList[clusterName].EnvFile);
index 6f399b193cae025b1b234b25fc932bfd82582f55..ba645a694aba0d91649472097b84b50247094895 100644 (file)
@@ -28,6 +28,8 @@ Launcher::Job::Job()
   _launch_date = getLaunchDate();
 
   _env_file = "";
+  _job_file = "";
+  _job_file_name = "";
   _work_directory = "";
   _local_directory = "";
   _result_directory = "";
@@ -98,13 +100,21 @@ void
 Launcher::Job::setMachineDefinition(const ParserResourcesType & machine_definition)
 {
   // Check machine_definition
+  std::string user_name = "";
   if (machine_definition.UserName == "")
   {
-    std::string mess = "Machine definition must define a user name !, machine name is: " + machine_definition.HostName;
-    throw LauncherException(mess);
+    user_name = getenv("USER");
+    if (user_name == "")
+    {
+      std::string mess = "You must define a user name: into your resource description or with env variable USER";
+      throw LauncherException(mess);
+    }
   }
+  else
+    user_name = machine_definition.UserName;
 
   _machine_definition = machine_definition;
+  _machine_definition.UserName = user_name;
 }
 
 ParserResourcesType 
@@ -114,7 +124,30 @@ Launcher::Job::getMachineDefinition()
 }
 
 void 
-Launcher::Job::setEnvFile(std::string & env_file)
+Launcher::Job::setJobFile(const std::string & job_file)
+{
+  // Check job file
+  if (job_file == "")
+  {
+    std::string mess = "Empty Job File is forbidden !";
+    throw LauncherException(mess);
+  }
+
+  _job_file = job_file;
+  std::string::size_type p1 = _job_file.find_last_of("/");
+  std::string::size_type p2 = _job_file.find_last_of(".");
+  _job_file_name = _job_file.substr(p1+1,p2-p1-1);
+  if (_job_file != "")
+    add_in_file(_job_file);
+}
+
+std::string
+Launcher::Job::getJobFile()
+{
+  return _job_file;
+}
+void 
+Launcher::Job::setEnvFile(const std::string & env_file)
 {
   _env_file = env_file;
   if (_env_file != "")
index 8405e0edbade36eee401372eaeb1af2399e58f2e..ec29383138479521e8af53c4da333d59860a5b68 100644 (file)
@@ -61,6 +61,7 @@ namespace Launcher
       ParserResourcesType getMachineDefinition();
       
       // Common parameters
+      virtual void setJobFile(const std::string & job_file);
       void setWorkDirectory(const std::string & work_directory);
       void setLocalDirectory(const std::string & local_directory);
       void setResultDirectory(const std::string & result_directory);
@@ -69,8 +70,9 @@ namespace Launcher
       void setMaximumDuration(const std::string & maximum_duration);
       void setMachineRequiredParams(const machineParams & machine_required_params);
       void setQueue(const std::string & queue);
-      void setEnvFile(std::string & env_file);
+      void setEnvFile(const std::string & env_file);
 
+      std::string getJobFile();
       std::string getWorkDirectory();
       std::string getLocalDirectory();
       std::string getResultDirectory();
@@ -103,6 +105,8 @@ namespace Launcher
 
       ParserResourcesType _machine_definition;
 
+      std::string _job_file;
+      std::string _job_file_name;
       std::string _work_directory;
       std::string _local_directory;
       std::string _result_directory;
index 2711fcf4c3569b4148b55ee45cd98cacdba18ab9..38a5330e22e516e23e896674ef984e4229213104 100644 (file)
 
 #include "Launcher_Job_Command.hxx"
 
-Launcher::Job_Command::Job_Command(const std::string & command)
-{
-  _command = command;
-}
+Launcher::Job_Command::Job_Command() {}
 
 Launcher::Job_Command::~Job_Command() {}
 
-void 
-Launcher::Job_Command::setCommand(const std::string & command)
-{
-  _command = command;
-}
-
-std::string 
-Launcher::Job_Command::getCommand()
-{
-  return _command;
-}
-
 void
 Launcher::Job_Command::update_job()
 {
 #ifdef WITH_LIBBATCH
   Batch::Parametre params = common_job_params();
-
-  // Files
-  // local file -> If file is not an absolute path, we apply _local_directory
-  // remote file -> get only file name from _in_files
-
-  // Copy command file
-  std::string local_file;
-  if (_command.substr(0, 1) == std::string("/"))
-    local_file = _command;
-  else
-    local_file = _local_directory + "/" + _command;
-  size_t found = _command.find_last_of("/");
-  std::string remote_file = _work_directory + "/" + _command.substr(found+1);
-  params[INFILE] += Batch::Couple(local_file, remote_file);
-
   params[EXECUTABLE] = buildCommandScript(params, _launch_date);
   _batch_job->setParametre(params);
 #endif
@@ -72,13 +42,11 @@ Launcher::Job_Command::buildCommandScript(Batch::Parametre params, std::string l
   std::string work_directory = params[WORKDIR].str();
 
   // File name
-  std::string::size_type p1 = _command.find_last_of("/");
-  std::string::size_type p2 = _command.find_last_of(".");
-  std::string command_name = _command.substr(p1+1,p2-p1-1);
-  std::string command_file_name = _command.substr(p1+1);
+  std::string::size_type p1 = _job_file.find_last_of("/");
+  std::string command_file_name = _job_file.substr(p1+1);
   
   std::string launch_date_port_file = launch_date;
-  std::string launch_script = "/tmp/runCommand_" + command_name + "_" + launch_date + ".sh";
+  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);
    
@@ -96,7 +64,7 @@ Launcher::Job_Command::buildCommandScript(Batch::Parametre params, std::string l
   launch_script_stream.flush();
   launch_script_stream.close();
   chmod(launch_script.c_str(), 0x1ED);
-  chmod(_command.c_str(), 0x1ED);
+  chmod(_job_file.c_str(), 0x1ED);
   return launch_script;
 }
 #endif
index 5171d49094fd318cb2bfb2e4c8e49f79adcdea17..a5ef7e4bf6e1097cd9dcda38da7f4f32525d6026 100644 (file)
@@ -33,22 +33,15 @@ namespace Launcher
   class Job_Command : virtual public Launcher::Job
   {
     public:
-      Job_Command(const std::string & command);
+      Job_Command();
       virtual ~Job_Command();
 
-      // Specific parameters
-      void setCommand(const std::string & command);
-      std::string getCommand();
-
       virtual void update_job();
 
 #ifdef WITH_LIBBATCH
     protected:
       std::string buildCommandScript(Batch::Parametre params, std::string launch_date);
 #endif
-
-    private:
-      std::string _command;
   };
 }
 
diff --git a/src/Launcher/Launcher_Job_PythonSALOME.cxx b/src/Launcher/Launcher_Job_PythonSALOME.cxx
new file mode 100644 (file)
index 0000000..219bfd7
--- /dev/null
@@ -0,0 +1,41 @@
+//  Copyright (C) 2009 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
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author: André RIBES - EDF R&D
+
+#include "Launcher_Job_PythonSALOME.hxx"
+
+
+Launcher::Job_PythonSALOME::Job_PythonSALOME() {}
+
+Launcher::Job_PythonSALOME::~Job_PythonSALOME() {}
+
+void 
+Launcher::Job_PythonSALOME::setJobFile(const std::string & job_file)
+{
+  Launcher::Job::setJobFile(job_file);
+}
+
+#ifdef WITH_LIBBATCH
+void
+Launcher::Job_PythonSALOME::addJobTypeSpecificScript(std::ofstream & launch_script_stream)
+{
+  launch_script_stream << _machine_definition.AppliPath << "/runSession -p $appli_port python " << _job_file_name << ".py > logs/python_" << _launch_date << ".log 2>&1" << std::endl;
+}
+#endif
+
diff --git a/src/Launcher/Launcher_Job_PythonSALOME.hxx b/src/Launcher/Launcher_Job_PythonSALOME.hxx
new file mode 100644 (file)
index 0000000..106d6f0
--- /dev/null
@@ -0,0 +1,41 @@
+//  Copyright (C) 2009 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
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author: André RIBES - EDF R&D
+
+#ifndef _LAUNCHER_JOB_PYTHONSALOME_HXX_
+#define _LAUNCHER_JOB_PYTHONSALOME_HXX_
+
+#include "Launcher_Job_SALOME.hxx"
+
+namespace Launcher
+{
+  class Job_PythonSALOME : virtual public Launcher::Job_SALOME
+  {
+    public:
+      Job_PythonSALOME();
+      virtual ~Job_PythonSALOME();
+
+      virtual void setJobFile(const std::string & job_file);
+      virtual void addJobTypeSpecificScript(std::ofstream & launch_script_stream);
+  };
+}
+
+#endif
+
+
diff --git a/src/Launcher/Launcher_Job_SALOME.cxx b/src/Launcher/Launcher_Job_SALOME.cxx
new file mode 100644 (file)
index 0000000..c9e571f
--- /dev/null
@@ -0,0 +1,120 @@
+//  Copyright (C) 2009 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
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author: André RIBES - EDF R&D
+
+#include "Launcher_Job_SALOME.hxx"
+
+Launcher::Job_SALOME::Job_SALOME() {}
+
+Launcher::Job_SALOME::~Job_SALOME() {}
+
+void 
+Launcher::Job_SALOME::setMachineDefinition(const ParserResourcesType & machine_definition)
+{
+  // Check machine_definition
+  if (machine_definition.AppliPath == "")
+  {
+    std::string mess = "Machine definition must define an application path !, machine name is: " + machine_definition.HostName;
+    throw LauncherException(mess);
+  }
+  Launcher::Job::setMachineDefinition(machine_definition);
+}
+
+void
+Launcher::Job_SALOME::update_job()
+{
+#ifdef WITH_LIBBATCH
+  Batch::Parametre params = common_job_params();
+  params[EXECUTABLE] = buildSalomeScript(params);
+  _batch_job->setParametre(params);
+#endif
+}
+
+#ifdef WITH_LIBBATCH
+std::string 
+Launcher::Job_SALOME::buildSalomeScript(Batch::Parametre params)
+{
+  // parameters
+  std::string work_directory = params[WORKDIR].str();
+
+  std::string launch_date_port_file = _launch_date;
+  std::string launch_script = "/tmp/runSalome_" + _job_file_name + "_" + _launch_date + ".sh";
+  std::ofstream launch_script_stream;
+  launch_script_stream.open(launch_script.c_str(), std::ofstream::out);
+   
+  // Begin of script
+  launch_script_stream << "#! /bin/sh -f" << std::endl;
+  launch_script_stream << "cd " << work_directory << std::endl;
+  if (_env_file != "")
+  {
+    std::string::size_type last = _env_file.find_last_of("/");
+    launch_script_stream << "source ./" << _env_file.substr(last+1) << std::endl;
+  }
+  launch_script_stream << "export SALOME_TMP_DIR=" << work_directory << "/logs" << std::endl;
+
+  // -- Generates Catalog Resources
+  std::string machine_protocol = "ssh";
+  if (_machine_definition.Protocol == rsh)
+    machine_protocol = "rsh";
+  
+  launch_script_stream << "if [ \"x$LIBBATCH_NODEFILE\" != \"x\" ]; then " << std::endl;
+  launch_script_stream << "CATALOG_FILE=" << work_directory << "/CatalogResources_" << _launch_date << ".xml" << std::endl;
+  launch_script_stream << "export USER_CATALOG_RESOURCES_FILE=" << "$CATALOG_FILE" << std::endl;
+  launch_script_stream << "echo '<!DOCTYPE ResourcesCatalog>'  > $CATALOG_FILE" << std::endl;
+  launch_script_stream << "echo '<resources>'                 >> $CATALOG_FILE" << std::endl;  
+  launch_script_stream << "cat $LIBBATCH_NODEFILE | sort -u | while read host"  << std::endl;
+  launch_script_stream << "do"                                                  << std::endl;
+  launch_script_stream << "echo '<machine hostname='\\\"$host\\\"                               >> $CATALOG_FILE" << std::endl;
+  launch_script_stream << "echo '         protocol=\"" << machine_protocol               << "\"' >> $CATALOG_FILE" << std::endl;
+  launch_script_stream << "echo '         userName=\"" << _machine_definition.UserName   << "\"' >> $CATALOG_FILE" << std::endl;
+  launch_script_stream << "echo '         appliPath=\"" << _machine_definition.AppliPath << "\"' >> $CATALOG_FILE" << std::endl;
+  launch_script_stream << "echo '/>'                                                             >> $CATALOG_FILE" << std::endl;
+  launch_script_stream << "done"                                 << std::endl;
+  launch_script_stream << "echo '</resources>' >> $CATALOG_FILE" << std::endl;
+  launch_script_stream << "fi" << std::endl;
+
+  // Launch SALOME with an appli
+  launch_script_stream << _machine_definition.AppliPath << "/runAppli --terminal  --ns-port-log=" << launch_date_port_file <<  " > logs/salome_" << _launch_date << ".log 2>&1" << std::endl;
+  launch_script_stream << "current=0\n"
+                      << "stop=20\n" 
+                      << "while ! test -f " << _machine_definition.AppliPath << "/" << launch_date_port_file << "\n"
+                      << "do\n"
+                      << "  sleep 2\n"
+                      << "  let current=current+1\n"
+                      << "  if [ \"$current\" -eq \"$stop\" ] ; then\n"
+                      << "    echo Error Naming Service failed ! >&2\n"
+                      << "    exit\n"
+                      << "  fi\n"
+                      << "done\n"
+                      << "appli_port=`cat " << _machine_definition.AppliPath << "/" << launch_date_port_file << "`\n";
+
+  // Call real job type
+  addJobTypeSpecificScript(launch_script_stream);
+
+  // End
+  launch_script_stream << _machine_definition.AppliPath << "/runSession -p $appli_port shutdownSalome.py" << std::endl;
+
+  // Return
+  launch_script_stream.flush();
+  launch_script_stream.close();
+  chmod(launch_script.c_str(), 0x1ED);
+  return launch_script;
+}
+#endif
+
diff --git a/src/Launcher/Launcher_Job_SALOME.hxx b/src/Launcher/Launcher_Job_SALOME.hxx
new file mode 100644 (file)
index 0000000..00cf4bd
--- /dev/null
@@ -0,0 +1,52 @@
+//  Copyright (C) 2009 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
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author: André RIBES - EDF R&D
+
+#ifndef _LAUNCHER_JOB_SALOME_HXX_
+#define _LAUNCHER_JOB_SALOME_HXX_
+
+#include "Launcher_Job.hxx"
+#include "Launcher.hxx"
+
+#ifdef WITH_LIBBATCH
+#include <Batch/Batch_Job.hxx>
+#endif
+
+namespace Launcher
+{
+  class Job_SALOME : virtual public Launcher::Job
+  {
+    public:
+      Job_SALOME();
+      virtual ~Job_SALOME();
+
+      virtual void setMachineDefinition(const ParserResourcesType & machine_definition);
+      virtual void update_job();
+
+#ifdef WITH_LIBBATCH
+    public:
+      std::string buildSalomeScript(Batch::Parametre params);
+      virtual void addJobTypeSpecificScript(std::ofstream & launch_script_stream) = 0;
+#endif
+  };
+}
+
+#endif
+
+
index 8f5347aa7314b1ac4029cffe80e65d6766af6690..42cbf9a21e8e50338bc0863522ca0c07e252aecf 100644 (file)
 #include "Launcher_Job_YACSFile.hxx"
 
 
-Launcher::Job_YACSFile::Job_YACSFile(const std::string & yacs_file)
-{
-  _yacs_file =  yacs_file;
-}
+Launcher::Job_YACSFile::Job_YACSFile() {}
 
 Launcher::Job_YACSFile::~Job_YACSFile() {}
 
-
 void 
-Launcher::Job_YACSFile::setYACSFile(const std::string & yacs_file)
-{
-  _yacs_file = yacs_file;
-}
-
-std::string 
-Launcher::Job_YACSFile::getYACSFile()
+Launcher::Job_YACSFile::setJobFile(const std::string & job_file)
 {
-  return _yacs_file;
-}
-
-void 
-Launcher::Job_YACSFile::setMachineDefinition(const ParserResourcesType & machine_definition)
-{
-  // Check machine_definition
-  if (machine_definition.AppliPath == "")
-  {
-    std::string mess = "Machine definition must define an application path !, machine name is: " + machine_definition.HostName;
-    throw LauncherException(mess);
-  }
-
-  Launcher::Job::setMachineDefinition(machine_definition);
+  Launcher::Job::setJobFile(job_file);
 }
 
 void
-Launcher::Job_YACSFile::update_job()
+Launcher::Job_YACSFile::addJobTypeSpecificScript(std::ofstream & launch_script_stream)
 {
-#ifdef WITH_LIBBATCH
-  Batch::Parametre params = common_job_params();
-
-  // Adding New Files for this type of job
-  // Copy YACS File
-  // local file -> If file is not an absolute path, we apply _local_directory
-  // remote file -> get only file name from _in_files
-  std::string local_file;
-  if (_yacs_file.substr(0, 1) == std::string("/"))
-    local_file = _yacs_file;
-  else
-    local_file = _local_directory + "/" + _yacs_file;
-  size_t found = _yacs_file.find_last_of("/");
-  std::string remote_file = _work_directory + "/" + _yacs_file.substr(found+1);
-  params[INFILE] += Batch::Couple(local_file, remote_file);
-
-  params[EXECUTABLE] = buildSalomeCouplingScript(params);
-
-  // Add in files -> yacs_file and launch_script
-  _batch_job->setParametre(params);
-#endif
-}
-
-#ifdef WITH_LIBBATCH
-std::string 
-Launcher::Job_YACSFile::buildSalomeCouplingScript(Batch::Parametre params)
-{
-  // parameters
-  std::string work_directory = params[WORKDIR].str();
-
-  // File name
-  std::string::size_type p1 = _yacs_file.find_last_of("/");
-  std::string::size_type p2 = _yacs_file.find_last_of(".");
-  std::string yacs_file_name = _yacs_file.substr(p1+1,p2-p1-1);
-  
-  std::string launch_date_port_file = _launch_date;
-  std::string launch_script = "/tmp/runSalome_" + yacs_file_name + "_" + _launch_date + ".sh";
-  std::ofstream launch_script_stream;
-  launch_script_stream.open(launch_script.c_str(), std::ofstream::out);
-   
-  // Begin of script
-  launch_script_stream << "#! /bin/sh -f" << std::endl;
-  launch_script_stream << "cd " << work_directory << std::endl;
-  if (_env_file != "")
-  {
-    std::string::size_type last = _env_file.find_last_of("/");
-    launch_script_stream << "source ./" << _env_file.substr(last+1) << std::endl;
-  }
-  launch_script_stream << "export SALOME_TMP_DIR=" << work_directory << "/logs" << std::endl;
-
-  // -- Generates Catalog Resources
-  std::string machine_protocol = "ssh";
-  if (_machine_definition.Protocol == rsh)
-    machine_protocol = "rsh";
-  
-  launch_script_stream << "if [ \"x$LIBBATCH_NODEFILE\" != \"x\" ]; then " << std::endl;
-  launch_script_stream << "CATALOG_FILE=" << work_directory << "/CatalogResources_" << _launch_date << ".xml" << std::endl;
-  launch_script_stream << "export USER_CATALOG_RESOURCES_FILE=" << "$CATALOG_FILE" << std::endl;
-  launch_script_stream << "echo '<!DOCTYPE ResourcesCatalog>'  > $CATALOG_FILE" << std::endl;
-  launch_script_stream << "echo '<resources>'                 >> $CATALOG_FILE" << std::endl;  
-  launch_script_stream << "cat $LIBBATCH_NODEFILE | sort -u | while read host"  << std::endl;
-  launch_script_stream << "do"                                                  << std::endl;
-  launch_script_stream << "echo '<machine hostname='\\\"$host\\\"                               >> $CATALOG_FILE" << std::endl;
-  launch_script_stream << "echo '         protocol=\"" << machine_protocol               << "\"' >> $CATALOG_FILE" << std::endl;
-  launch_script_stream << "echo '         userName=\"" << _machine_definition.UserName   << "\"' >> $CATALOG_FILE" << std::endl;
-  launch_script_stream << "echo '         appliPath=\"" << _machine_definition.AppliPath << "\"' >> $CATALOG_FILE" << std::endl;
-  launch_script_stream << "echo '/>'                                                             >> $CATALOG_FILE" << std::endl;
-  launch_script_stream << "done"                                 << std::endl;
-  launch_script_stream << "echo '</resources>' >> $CATALOG_FILE" << std::endl;
-  launch_script_stream << "fi" << std::endl;
-
-  // Launch SALOME with an appli
-  launch_script_stream << _machine_definition.AppliPath << "/runAppli --terminal  --ns-port-log=" << launch_date_port_file <<  " > logs/salome_" << _launch_date << ".log 2>&1" << std::endl;
-  launch_script_stream << "current=0\n"
-                      << "stop=20\n" 
-                      << "while ! test -f " << _machine_definition.AppliPath << "/" << launch_date_port_file << "\n"
-                      << "do\n"
-                      << "  sleep 2\n"
-                      << "  let current=current+1\n"
-                      << "  if [ \"$current\" -eq \"$stop\" ] ; then\n"
-                      << "    echo Error Naming Service failed ! >&2\n"
-                      << "    exit\n"
-                      << "  fi\n"
-                      << "done\n"
-                      << "appli_port=`cat " << _machine_definition.AppliPath << "/" << launch_date_port_file << "`\n";
-  launch_script_stream << _machine_definition.AppliPath << "/runSession -p $appli_port driver " << yacs_file_name << ".xml > logs/yacs_" << _launch_date << ".log 2>&1" << std::endl;
-  launch_script_stream << _machine_definition.AppliPath << "/runSession -p $appli_port shutdownSalome.py" << std::endl;
-
-  // Return
-  launch_script_stream.flush();
-  launch_script_stream.close();
-  chmod(launch_script.c_str(), 0x1ED);
-  return launch_script;
+  launch_script_stream << _machine_definition.AppliPath << "/runSession -p $appli_port driver " << _job_file_name << ".xml > logs/yacs_" << _launch_date << ".log 2>&1" << std::endl;
 }
-#endif
index 229a0b29c36becf68d6baf8f0360c54755ec7054..b789226b1b5769a5577cf62d1e98d863927067d8 100644 (file)
 #ifndef _LAUNCHER_JOB_YACSFILE_HXX_
 #define _LAUNCHER_JOB_YACSFILE_HXX_
 
-#include "Launcher_Job.hxx"
-#include "Launcher.hxx"
-
-#ifdef WITH_LIBBATCH
-#include <Batch/Batch_Job.hxx>
-#endif
+#include "Launcher_Job_SALOME.hxx"
 
 namespace Launcher
 {
-  class Job_YACSFile : virtual public Launcher::Job
+  class Job_YACSFile : virtual public Launcher::Job_SALOME
   {
     public:
-      Job_YACSFile(const std::string & yacs_file);
+      Job_YACSFile();
       virtual ~Job_YACSFile();
 
-      // Specific parameters
-      void setYACSFile(const std::string & yacs_file);
-      std::string getYACSFile();
-
-      virtual void setMachineDefinition(const ParserResourcesType & machine_definition);
-
-      virtual void update_job();
-
-#ifdef WITH_LIBBATCH
-    protected:
-      std::string buildSalomeCouplingScript(Batch::Parametre params);
-#endif
-
-    private:
-      std::string _yacs_file;
+      virtual void setJobFile(const std::string & job_file);
+      virtual void addJobTypeSpecificScript(std::ofstream & launch_script_stream);
   };
 }
 
index 847d97aeaffa15b9a774f1c276a2348f084d5a59..ab11e0daff57234c5ff9f338860b376a48803d2a 100644 (file)
@@ -36,6 +36,8 @@ salomeinclude_HEADERS = \
   Launcher_Utils.hxx \
   Launcher_Job.hxx \
   Launcher_Job_Command.hxx \
+  Launcher_Job_SALOME.hxx \
+  Launcher_Job_PythonSALOME.hxx \
   Launcher_Job_YACSFile.hxx \
   Launcher.hxx
 
@@ -119,6 +121,8 @@ libLauncher_la_SOURCES=\
        Launcher_Utils.hxx \
        Launcher_Job.cxx \
        Launcher_Job_Command.cxx \
+       Launcher_Job_SALOME.cxx \
+       Launcher_Job_PythonSALOME.cxx \
        Launcher_Job_YACSFile.cxx \
        Launcher.cxx
 
index debe563869cd73a516277a2341308d667dbda592..4459c76fabe90d5dd898612d6d4bfeadeafc3719 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "Launcher_Job_Command.hxx"
 #include "Launcher_Job_YACSFile.hxx"
+#include "Launcher_Job_PythonSALOME.hxx"
 
 #ifdef WIN32
 # include <process.h>
@@ -85,7 +86,7 @@ SALOME_Launcher::createJob(const Engines::JobParameters & job_parameters)
 {
   std::string job_type = job_parameters.job_type.in();
   
-  if (job_type != "command" and job_type != "yacs_file")
+  if (job_type != "command" and job_type != "yacs_file" and job_type != "python_salome")
   {
     std::string message("SALOME_Launcher::createJob: bad job type: ");
     message += job_type;
@@ -95,26 +96,11 @@ SALOME_Launcher::createJob(const Engines::JobParameters & job_parameters)
   Launcher::Job * new_job; // It is Launcher_cpp that is going to destroy it
 
   if (job_type == "command")
-  {
-    std::string command = job_parameters.command.in();
-    if (command == "")
-    {
-      std::string message("SALOME_Launcher::createJob: command is empty !");
-      THROW_SALOME_CORBA_EXCEPTION(message.c_str(), SALOME::INTERNAL_ERROR);
-    }
-    Launcher::Job_Command * job = new Launcher::Job_Command(command);
-    new_job = job;
-  }
+    new_job = new Launcher::Job_Command();
   else if (job_type == "yacs_file")
-  {
-    std::string yacs_file = job_parameters.yacs_file.in();
-    if (yacs_file == "")
-    {
-      std::string message("SALOME_Launcher::createJob: yacs_file is empty !");
-      THROW_SALOME_CORBA_EXCEPTION(message.c_str(), SALOME::INTERNAL_ERROR);
-    }
-    new_job = new Launcher::Job_YACSFile(yacs_file);
-  }
+    new_job = new Launcher::Job_YACSFile();
+  else if (job_type == "python_salome")
+    new_job = new Launcher::Job_PythonSALOME();
  
   // Directories
   std::string work_directory = job_parameters.work_directory.in();
@@ -124,6 +110,18 @@ SALOME_Launcher::createJob(const Engines::JobParameters & job_parameters)
   new_job->setLocalDirectory(local_directory);
   new_job->setResultDirectory(result_directory);
 
+  // Job File
+  std::string job_file = job_parameters.job_file.in();
+  try
+  {
+    new_job->setJobFile(job_file);
+  }
+  catch(const LauncherException &ex)
+  {
+    INFOS(ex.msg.c_str());
+    THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::INTERNAL_ERROR);
+  }
+
   // Files
   std::string env_file = job_parameters.env_file.in();
   new_job->setEnvFile(env_file);