Salome HOME
Fix SHAPER_HDF_BearingSeparator test after 520aea
[modules/kernel.git] / src / Launcher / Launcher_Job_PythonSALOME.cxx
index b192defa8af89131dd149532b2f202bd0995d64e..6b803e36e37dc18f9a54755987066bff90311114 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2009-2021  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // Author: AndrĂ© RIBES - EDF R&D
 //
 #include "Launcher_Job_PythonSALOME.hxx"
+#include <sys/stat.h>
 
+const char Launcher::Job_PythonSALOME::TYPE_NAME[] = "python_salome";
 
-Launcher::Job_PythonSALOME::Job_PythonSALOME() {_job_type = "python_salome";}
+Launcher::Job_PythonSALOME::Job_PythonSALOME()
+{
+  _job_type = Launcher::Job_PythonSALOME::TYPE_NAME;
+}
 
 Launcher::Job_PythonSALOME::~Job_PythonSALOME() {}
 
-void 
+void
 Launcher::Job_PythonSALOME::setJobFile(const std::string & job_file)
 {
   Launcher::Job::setJobFile(job_file);
@@ -35,5 +40,10 @@ Launcher::Job_PythonSALOME::setJobFile(const std::string & job_file)
 void
 Launcher::Job_PythonSALOME::addJobTypeSpecificScript(std::ofstream & launch_script_stream)
 {
-  launch_script_stream << _resource_definition.AppliPath << "/runSession -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 -- python " << _job_file_name_complete << " > logs/python_" << _launch_date << ".log 2>&1" << std::endl;
+  else
+      launch_script_stream << _resource_definition.AppliPath << "/salome shell -- python " << _job_file_name_complete << " > logs/python_" << _launch_date << ".log 2>&1" << std::endl;
 }