#endif
#include <sstream>
+#include <sys/stat.h>
const char Launcher::Job_CommandSALOME::TYPE_NAME[] = "command_salome";
std::string Launcher::Job_CommandSALOME::runCommandString()
{
std::ostringstream result;
- result << _resource_definition.AppliPath
- << "/salome shell ./"
- << _job_file_name_complete;
+ struct stat statbuf;
+ if(stat(getenv("APPLI"), &statbuf) ==0 && S_ISREG(statbuf.st_mode))
+ // case of a salome launcher file
+ result << _resource_definition.AppliPath
+ << " shell ./"
+ << _job_file_name_complete;
+ else
+ // case of a salome appli dir
+ result << _resource_definition.AppliPath
+ << "/salome shell ./"
+ << _job_file_name_complete;
return result.str();
}
#endif
// Author: André RIBES - EDF R&D
//
#include "Launcher_Job_PythonSALOME.hxx"
+#include <sys/stat.h>
const char Launcher::Job_PythonSALOME::TYPE_NAME[] = "python_salome";
void
Launcher::Job_PythonSALOME::addJobTypeSpecificScript(std::ofstream & launch_script_stream)
{
- launch_script_stream << _resource_definition.AppliPath << "/salome shell -p \"$appli_port\" python " << _job_file_name_complete << " > logs/python_" << _launch_date << ".log 2>&1" << std::endl;
+ struct stat statbuf;
+ if(stat(getenv("APPLI"), &statbuf) ==0 && S_ISREG(statbuf.st_mode))
+ // case where AppliPath hold a salome launcher file
+ launch_script_stream << _resource_definition.AppliPath << " shell -p \"$appli_port\" python " << _job_file_name_complete << " > logs/python_" << _launch_date << ".log 2>&1" << std::endl;
+ else
+ launch_script_stream << _resource_definition.AppliPath << "/salome shell -p \"$appli_port\" python " << _job_file_name_complete << " > logs/python_" << _launch_date << ".log 2>&1" << std::endl;
}
#define _chmod chmod
#include <process.h>
#endif
+#include <sys/stat.h>
#include <sstream>
#else
str_pid << ::getpid();
#endif
- std::string launch_script = Kernel_Utils::GetTmpDir() + "runSalome_" + _job_file_name + "_" + _launch_date + "-" + str_pid.str() + ".sh";
+ struct stat statbuf;
+ // true if APPLI holds a salome file launcher (in state of an application directory)
+ bool is_launcher_file=stat(getenv("APPLI"), &statbuf) ==0 && S_ISREG(statbuf.st_mode);
+ std::string launch_tmp_dir = Kernel_Utils::GetTmpDir();
+ std::string launch_script = launch_tmp_dir + "runSalome_" + _job_file_name + "_" + _launch_date + "-" + str_pid.str() + ".sh";
std::ofstream launch_script_stream;
launch_script_stream.open(launch_script.c_str(),
std::ofstream::out
launch_script_stream << "fi" << std::endl;
// Create file for ns-port-log
- launch_script_stream << "NS_PORT_FILE_PATH=$(mktemp " << _resource_definition.AppliPath << "/USERS/nsport_XXXXXX) &&\n";
+ if (is_launcher_file)
+ // for a salome application file, we write NS_PORT_FILE_PATH in launch_tmp_dir
+ launch_script_stream << "NS_PORT_FILE_PATH=$(mktemp " << launch_tmp_dir << "nsport_XXXXXX) &&\n";
+ else
+ launch_script_stream << "NS_PORT_FILE_PATH=$(mktemp " << _resource_definition.AppliPath << "/USERS/nsport_XXXXXX) &&\n";
// Launch SALOME with an appli
- launch_script_stream << _resource_definition.AppliPath << "/salome start --terminal --ns-port-log=\"$NS_PORT_FILE_PATH\" --server-launch-mode=fork ";
+ if (is_launcher_file)
+ launch_script_stream << _resource_definition.AppliPath << " start --terminal --ns-port-log=\"$NS_PORT_FILE_PATH\" --server-launch-mode=fork ";
+ else
+ launch_script_stream << _resource_definition.AppliPath << "/salome start --terminal --ns-port-log=\"$NS_PORT_FILE_PATH\" --server-launch-mode=fork ";
launch_script_stream << "> logs/salome_" << _launch_date << ".log 2>&1 &&" << std::endl;
launch_script_stream << "current=0 &&\n"
<< "stop=20 &&\n"
launch_script_stream << "echo $? > logs/exit_code.log" << std::endl;
// End
- launch_script_stream << _resource_definition.AppliPath << "/salome kill \"$appli_port\"" << std::endl;
+ if (is_launcher_file)
+ launch_script_stream << _resource_definition.AppliPath << " kill \"$appli_port\"" << std::endl;
+ else
+ launch_script_stream << _resource_definition.AppliPath << "/salome kill \"$appli_port\"" << std::endl;
// Return
launch_script_stream.flush();
//
#include "Launcher_Job_YACSFile.hxx"
#include <sstream>
+#include <sys/stat.h>
const char Launcher::Job_YACSFile::TYPE_NAME[] = "yacs_file";
void
Launcher::Job_YACSFile::addJobTypeSpecificScript(std::ofstream & launch_script_stream)
{
- launch_script_stream << _resource_definition.AppliPath << "/salome shell -p \"$appli_port\" -- driver -k\"$appli_port\" " << _job_file_name_complete;
+ struct stat statbuf;
+ if(stat(getenv("APPLI"), &statbuf) ==0 && S_ISREG(statbuf.st_mode))
+ // case of a salome launcher file
+ launch_script_stream << _resource_definition.AppliPath << " shell -p \"$appli_port\" -- driver -k\"$appli_port\" " << _job_file_name_complete;
+ else
+ launch_script_stream << _resource_definition.AppliPath << "/salome shell -p \"$appli_port\" -- driver -k\"$appli_port\" " << _job_file_name_complete;
if (_dumpState > 0)
launch_script_stream << " --dump=" << _dumpState;
if(! _yacsDriverOptions.empty())
resource.Protocol = sh;
resource.Batch = none;
#ifndef WIN32
+ struct stat statbuf;
if (getenv("HOME") != NULL && getenv("APPLI") != NULL)
{
- resource.AppliPath = string(getenv("HOME")) + "/" + getenv("APPLI");
+ if (stat(getenv("APPLI"), &statbuf) ==0 && S_ISREG(statbuf.st_mode))
+ {
+ // if $APPLI is a regular file, we asume it's a salome Launcher file
+ resource.AppliPath = string(getenv("APPLI"));
+ }
+ else
+ {
+ resource.AppliPath = string(getenv("HOME")) + "/" + getenv("APPLI");
+ }
}
string tmpdir = "/tmp";
if (getenv("TMPDIR") != NULL)