From: ribes Date: Wed, 25 Nov 2009 14:49:06 +0000 (+0000) Subject: - Adding new type of Job: python_salome X-Git-Tag: new_launcher_alpha_091125 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2d2ab8a827d2a41e58c36fc878c734c2c4bb17a7;p=modules%2Fkernel.git - Adding new type of Job: python_salome - Using USER env variable if UserName is not defined in the resource description --- diff --git a/idl/SALOME_ContainerManager.idl b/idl/SALOME_ContainerManager.idl index f886b8c62..ebd2c47f9 100644 --- a/idl/SALOME_ContainerManager.idl +++ b/idl/SALOME_ContainerManager.idl @@ -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; diff --git a/src/Launcher/Launcher.cxx b/src/Launcher/Launcher.cxx index fffee68cf..c77c680b2 100644 --- a/src/Launcher/Launcher.cxx +++ b/src/Launcher/Launcher.cxx @@ -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); diff --git a/src/Launcher/Launcher_Job.cxx b/src/Launcher/Launcher_Job.cxx index 6f399b193..ba645a694 100644 --- a/src/Launcher/Launcher_Job.cxx +++ b/src/Launcher/Launcher_Job.cxx @@ -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 != "") diff --git a/src/Launcher/Launcher_Job.hxx b/src/Launcher/Launcher_Job.hxx index 8405e0edb..ec2938313 100644 --- a/src/Launcher/Launcher_Job.hxx +++ b/src/Launcher/Launcher_Job.hxx @@ -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; diff --git a/src/Launcher/Launcher_Job_Command.cxx b/src/Launcher/Launcher_Job_Command.cxx index 2711fcf4c..38a5330e2 100644 --- a/src/Launcher/Launcher_Job_Command.cxx +++ b/src/Launcher/Launcher_Job_Command.cxx @@ -20,45 +20,15 @@ #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 diff --git a/src/Launcher/Launcher_Job_Command.hxx b/src/Launcher/Launcher_Job_Command.hxx index 5171d4909..a5ef7e4bf 100644 --- a/src/Launcher/Launcher_Job_Command.hxx +++ b/src/Launcher/Launcher_Job_Command.hxx @@ -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 index 000000000..219bfd70a --- /dev/null +++ b/src/Launcher/Launcher_Job_PythonSALOME.cxx @@ -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 index 000000000..106d6f0b3 --- /dev/null +++ b/src/Launcher/Launcher_Job_PythonSALOME.hxx @@ -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 index 000000000..c9e571fbf --- /dev/null +++ b/src/Launcher/Launcher_Job_SALOME.cxx @@ -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 '' > $CATALOG_FILE" << std::endl; + launch_script_stream << "echo '' >> $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 '> $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 '' >> $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 index 000000000..00cf4bd2c --- /dev/null +++ b/src/Launcher/Launcher_Job_SALOME.hxx @@ -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 +#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 + + diff --git a/src/Launcher/Launcher_Job_YACSFile.cxx b/src/Launcher/Launcher_Job_YACSFile.cxx index 8f5347aa7..42cbf9a21 100644 --- a/src/Launcher/Launcher_Job_YACSFile.cxx +++ b/src/Launcher/Launcher_Job_YACSFile.cxx @@ -21,134 +21,18 @@ #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 '' > $CATALOG_FILE" << std::endl; - launch_script_stream << "echo '' >> $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 '> $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 '' >> $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 diff --git a/src/Launcher/Launcher_Job_YACSFile.hxx b/src/Launcher/Launcher_Job_YACSFile.hxx index 229a0b29c..b789226b1 100644 --- a/src/Launcher/Launcher_Job_YACSFile.hxx +++ b/src/Launcher/Launcher_Job_YACSFile.hxx @@ -21,36 +21,18 @@ #ifndef _LAUNCHER_JOB_YACSFILE_HXX_ #define _LAUNCHER_JOB_YACSFILE_HXX_ -#include "Launcher_Job.hxx" -#include "Launcher.hxx" - -#ifdef WITH_LIBBATCH -#include -#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); }; } diff --git a/src/Launcher/Makefile.am b/src/Launcher/Makefile.am index 847d97aea..ab11e0daf 100644 --- a/src/Launcher/Makefile.am +++ b/src/Launcher/Makefile.am @@ -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 diff --git a/src/Launcher/SALOME_Launcher.cxx b/src/Launcher/SALOME_Launcher.cxx index debe56386..4459c76fa 100644 --- a/src/Launcher/SALOME_Launcher.cxx +++ b/src/Launcher/SALOME_Launcher.cxx @@ -28,6 +28,7 @@ #include "Launcher_Job_Command.hxx" #include "Launcher_Job_YACSFile.hxx" +#include "Launcher_Job_PythonSALOME.hxx" #ifdef WIN32 # include @@ -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);