ENABLE_TESTING()
-find_package (PLATFORM)
find_package (Threads)
IF (NOT CMAKE_USE_PTHREADS_INIT)
MESSAGE(FATAL_ERROR "Mandatory library pthread not found")
FIND_LIBRARY(LSF_LIBRARY lsf)
FIND_LIBRARY(LSF_BAT_LIBRARY bat)
-SET(LSF_FOUND ${LSF_INCLUDE_DIR} AND ${LSF_LIBRARY} AND ${LSF_BAT_LIBRARY})
+IF (LSF_INCLUDE_DIR AND LSF_LIBRARY AND LSF_BAT_LIBRARY)
+ SET(LSF_FOUND True)
+ENDIF (LSF_INCLUDE_DIR AND LSF_LIBRARY AND LSF_BAT_LIBRARY)
IF (LSF_FOUND)
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-INCLUDE (CheckIncludeFile)
-INCLUDE (CheckLibraryExists)
-
IF (NOT PBS_FIND_QUIETLY)
MESSAGE(STATUS "Looking for PBS...")
ENDIF (NOT PBS_FIND_QUIETLY)
FIND_PATH(PBS_INCLUDE_DIR pbs_ifl.h)
FIND_LIBRARY(PBS_LIBRARY pbs)
-SET(PBS_FOUND ${PBS_INCLUDE_DIR} AND ${PBS_LIBRARY})
+IF (PBS_INCLUDE_DIR AND PBS_LIBRARY)
+ SET(PBS_FOUND True)
+ENDIF (PBS_INCLUDE_DIR AND PBS_LIBRARY)
IF (PBS_FOUND)
+++ /dev/null
-# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
-#
-# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-#
-# 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
-#
-MARK_AS_ADVANCED(ISSUE)
-FIND_FILE(ISSUE issue /etc)
-IF(ISSUE)
- SET(WINDOWS 0)
-ELSE()
- SET(WINDOWS 1)
-ENDIF(ISSUE)
-
-IF(WINDOWS)
- SET(MACHINE WINDOWS)
- SET(PLATFORM_CPPFLAGS)
- SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -DWNT)
- SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -DPPRO_NT)
- SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} /W0)
- # # SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -DWNT -D_CRT_SECURE_NO_WARNINGS)
- # # SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -D_WIN32_WINNT=0x0500)
- # SET(RM del)
-ELSE(WINDOWS)
- SET(MACHINE PCLINUX)
- SET(PLATFORM_CPPFLAGS)
- # SET(RM /bin/rm)
-ENDIF(WINDOWS)
-
-IF(WINDOWS)
- SET(CMAKE_BUILD_TYPE $ENV{CMAKE_BUILD_TYPE})
- IF(CMAKE_BUILD_TYPE STREQUAL Release)
- MARK_AS_ADVANCED(CLEAR CMAKE_CONFIGURATION_TYPES)
- SET(CMAKE_CONFIGURATION_TYPES Release CACHE STRING "compilation types" FORCE)
- ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
-ENDIF(WINDOWS)
-
-IF(WINDOWS)
- SET(CMAKE_INSTALL_PREFIX_ENV $ENV{CMAKE_INSTALL_PREFIX})
- IF(CMAKE_INSTALL_PREFIX_ENV)
- SET(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX_ENV} CACHE PATH "installation prefix" FORCE)
- ENDIF(CMAKE_INSTALL_PREFIX_ENV)
-ENDIF(WINDOWS)
-
-## SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -D_DEBUG_)
-
-#SET(RCP rcp)
-#SET(RSH rsh)
-#SET(RCP rcp)
MESSAGE(STATUS "Looking for Python...")
ENDIF (NOT Python_FIND_QUIETLY)
-IF(WINDOWS)
- IF(CMAKE_BUILD_TYPE STREQUAL Release)
- FIND_PROGRAM(PYTHON_EXECUTABLE python)
- ELSE(CMAKE_BUILD_TYPE STREQUAL Release)
- FIND_PROGRAM(PYTHON_EXECUTABLE python_d)
- ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
-ELSE(WINDOWS)
- FIND_PROGRAM(PYTHON_EXECUTABLE python DOC "Python interpreter")
-ENDIF(WINDOWS)
-
-EXECUTE_PROCESS(
- COMMAND ${PYTHON_EXECUTABLE} -c "import sys; sys.stdout.write(sys.version[:3])"
- OUTPUT_VARIABLE PYTHON_VERSION
+IF(WIN32 AND NOT CMAKE_BUILD_TYPE STREQUAL Release)
+ FIND_PROGRAM(PYTHON_DEBUG python_d)
+ mark_as_advanced(PYTHON_DEBUG)
+ENDIF(WIN32 AND NOT CMAKE_BUILD_TYPE STREQUAL Release)
+
+IF (PYTHON_DEBUG)
+ SET(PYTHON_EXECUTABLE ${PYTHON_DEBUG} CACHE STRING "Python interpreter")
+ELSE (PYTHON_DEBUG)
+ FIND_PROGRAM(PYTHON_EXECUTABLE python DOC "Python interpreter")
+ENDIF (PYTHON_DEBUG)
+
+IF (PYTHON_EXECUTABLE)
+ EXECUTE_PROCESS(
+ COMMAND ${PYTHON_EXECUTABLE} -c "import sys; sys.stdout.write(sys.version[:3])"
+ OUTPUT_VARIABLE PYTHON_VERSION
)
-SET(PYTHON_ROOT ${PYTHON_EXECUTABLE})
-GET_FILENAME_COMPONENT(PYTHON_ROOT ${PYTHON_ROOT} PATH)
-GET_FILENAME_COMPONENT(PYTHON_ROOT ${PYTHON_ROOT} PATH)
-
-FIND_PATH(PYTHON_INCLUDE_PATH Python.h
- PATHS ${PYTHON_ROOT}/include ${PYTHON_ROOT}/include/python${PYTHON_VERSION}
- DOC "Python include path")
-
-IF(WINDOWS)
- STRING(REPLACE "." "" PYTHON_VERSION_WITHOUT_DOT ${PYTHON_VERSION})
- IF(CMAKE_BUILD_TYPE STREQUAL Release)
- FIND_LIBRARY(PYTHON_LIBRARIES python${PYTHON_VERSION_WITHOUT_DOT} ${PYTHON_ROOT}/libs DOC "Python libraries")
- ELSE(CMAKE_BUILD_TYPE STREQUAL Release)
- FIND_LIBRARY(PYTHON_LIBRARIES python${PYTHON_VERSION_WITHOUT_DOT}_d ${PYTHON_ROOT}/libs DOC "Python libraries")
- ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
-ELSE(WINDOWS)
- FIND_LIBRARY(PYTHON_LIBRARIES python${PYTHON_VERSION} ${PYTHON_ROOT}/lib DOC "Python libraries")
-ENDIF(WINDOWS)
-
-SET(PYTHON_INCLUDES -I${PYTHON_INCLUDE_PATH})
-SET(PYTHON_LIBS ${PYTHON_LIBRARIES})
-
-IF(WINDOWS)
- IF(CMAKE_BUILD_TYPE STREQUAL Release)
- ELSE(CMAKE_BUILD_TYPE STREQUAL Release)
- SET(PYTHON_INCLUDES ${PYTHON_INCLUDES} -DHAVE_DEBUG_PYTHON)
- ENDIF(CMAKE_BUILD_TYPE STREQUAL Release)
-ENDIF(WINDOWS)
-
-SET(Python_FOUND ${PYTHON_EXECUTABLE} AND ${PYTHON_LIBRARIES} AND ${PYTHON_INCLUDE_PATH})
+ SET(PYTHON_ROOT ${PYTHON_EXECUTABLE})
+ GET_FILENAME_COMPONENT(PYTHON_ROOT ${PYTHON_ROOT} PATH)
+ GET_FILENAME_COMPONENT(PYTHON_ROOT ${PYTHON_ROOT} PATH)
+
+ FIND_PATH(PYTHON_INCLUDE_PATH Python.h
+ PATHS ${PYTHON_ROOT}/include ${PYTHON_ROOT}/include/python${PYTHON_VERSION}
+ DOC "Python include path")
+
+ IF(WIN32)
+ STRING(REPLACE "." "" PYTHON_VERSION_WITHOUT_DOT ${PYTHON_VERSION})
+ IF(PYTHON_DEBUG)
+ FIND_LIBRARY(PYTHON_LIBRARIES python${PYTHON_VERSION_WITHOUT_DOT}_d ${PYTHON_ROOT}/libs DOC "Python libraries")
+ ELSE(PYTHON_DEBUG)
+ FIND_LIBRARY(PYTHON_LIBRARIES python${PYTHON_VERSION_WITHOUT_DOT} ${PYTHON_ROOT}/libs DOC "Python libraries")
+ ENDIF(PYTHON_DEBUG)
+ ELSE(WIN32)
+ FIND_LIBRARY(PYTHON_LIBRARIES python${PYTHON_VERSION} ${PYTHON_ROOT}/lib DOC "Python libraries")
+ ENDIF(WIN32)
+
+ SET(PYTHON_INCLUDES -I${PYTHON_INCLUDE_PATH})
+ SET(PYTHON_LIBS ${PYTHON_LIBRARIES})
+
+ IF(PYTHON_DEBUG)
+ SET(PYTHON_INCLUDES ${PYTHON_INCLUDES} -DHAVE_DEBUG_PYTHON)
+ ENDIF(PYTHON_DEBUG)
+ENDIF (PYTHON_EXECUTABLE)
+
+IF(PYTHON_EXECUTABLE AND PYTHON_LIBRARIES AND PYTHON_INCLUDE_PATH)
+ SET(Python_FOUND True)
+ENDIF(PYTHON_EXECUTABLE AND PYTHON_LIBRARIES AND PYTHON_INCLUDE_PATH)
IF (Python_FOUND)
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-MESSAGE("")
-MESSAGE("**************** Summary ****************")
-MESSAGE("")
+MESSAGE(STATUS "")
+MESSAGE(STATUS "**************** Summary ****************")
+MESSAGE(STATUS "")
IF (BUILD_LSF_INTERFACE)
IF (LSF_FOUND)
- MESSAGE("LSF ................................. Yes")
+ MESSAGE(STATUS "LSF ................................. Yes")
ELSE (LSF_FOUND)
- MESSAGE("LSF ........................... Not found")
+ MESSAGE(STATUS "LSF ........................... Not found")
ENDIF (LSF_FOUND)
ELSE (BUILD_LSF_INTERFACE)
- MESSAGE("LSF ....................... Not requested")
+ MESSAGE(STATUS "LSF ....................... Not requested")
ENDIF (BUILD_LSF_INTERFACE)
IF (BUILD_PBS_INTERFACE)
IF (PBS_FOUND)
- MESSAGE("PBS ................................. Yes")
+ MESSAGE(STATUS "PBS ................................. Yes")
ELSE (PBS_FOUND)
- MESSAGE("PBS ........................... Not found")
+ MESSAGE(STATUS "PBS ........................... Not found")
ENDIF (PBS_FOUND)
ELSE (BUILD_PBS_INTERFACE)
- MESSAGE("PBS ....................... Not requested")
+ MESSAGE(STATUS "PBS ....................... Not requested")
ENDIF (BUILD_PBS_INTERFACE)
IF (BUILD_LOCAL_SUBMISSION)
- MESSAGE("Local submission .................... Yes")
+ MESSAGE(STATUS "Local submission .................... Yes")
ELSE (BUILD_LOCAL_SUBMISSION)
- MESSAGE("Local submission .......... Not requested")
+ MESSAGE(STATUS "Local submission .......... Not requested")
ENDIF (BUILD_LOCAL_SUBMISSION)
IF (BUILD_PYTHON_WRAPPING)
- IF (PYTHON_INCLUDE_PATH AND PYTHON_LIBRARIES AND SWIG_FOUND)
- MESSAGE("Python wrapping ..................... Yes")
- ELSE (PYTHON_INCLUDE_PATH AND PYTHON_LIBRARIES AND SWIG_FOUND)
- MESSAGE("Python wrapping ............... Not found")
- ENDIF (PYTHON_INCLUDE_PATH AND PYTHON_LIBRARIES AND SWIG_FOUND)
+ IF (Python_FOUND AND SWIG_FOUND)
+ MESSAGE(STATUS "Python wrapping ..................... Yes")
+ ELSE (Python_FOUND AND SWIG_FOUND)
+ MESSAGE(STATUS "Python wrapping ............... Not found")
+ ENDIF (Python_FOUND AND SWIG_FOUND)
ELSE (BUILD_PYTHON_WRAPPING)
- MESSAGE("Python wrapping ........... Not requested")
+ MESSAGE(STATUS "Python wrapping ........... Not requested")
ENDIF (BUILD_PYTHON_WRAPPING)
IF (Makeinfo_FOUND)
- MESSAGE("Makeinfo ............................ Yes")
+ MESSAGE(STATUS "Makeinfo ............................ Yes")
ELSE (Makeinfo_FOUND)
- MESSAGE("Makeinfo ...................... Not found")
+ MESSAGE(STATUS "Makeinfo ...................... Not found")
ENDIF (Makeinfo_FOUND)
-MESSAGE("")
-MESSAGE("************** End Summary **************")
-MESSAGE("")
+MESSAGE(STATUS "")
+MESSAGE(STATUS "************** End Summary **************")
+MESSAGE(STATUS "")
SET (TEXI_FILE ${CMAKE_CURRENT_SOURCE_DIR}/Batch.texi)
ADD_CUSTOM_TARGET(doc ALL
- ${MAKEINFO_EXECUTABLE} --html ${TEXI_FILE}
+ ${MAKEINFO_EXECUTABLE} --html ${TEXI_FILE} -I ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${TEXI_FILE}
)
SET(HDR_FILES_BUILD CACHE INTERNAL "")
-
add_library (Batch SHARED ${SRC_FILES})
include_directories(${CMAKE_BINARY_DIR})
target_link_libraries(Batch ${CMAKE_THREAD_LIBS_INIT})
+IF (WIN32)
+ target_link_libraries(Batch ws2_32)
+ENDIF (WIN32)
+
# If necessary, activate all warnings (useful for debugging and code cleaning)
# add_definitions(-Wall -Werror -ansi -pedantic)
INSTALL(TARGETS Batch DESTINATION lib)
INSTALL(FILES ${HDR_FILES} DESTINATION include/Batch)
-IF (BUILD_PYTHON_WRAPPING AND PYTHON_INCLUDE_PATH AND PYTHON_LIBRARIES AND SWIG_FOUND)
+IF (BUILD_PYTHON_WRAPPING AND Python_FOUND AND SWIG_FOUND)
add_subdirectory (Python)
-ENDIF (BUILD_PYTHON_WRAPPING AND PYTHON_INCLUDE_PATH AND PYTHON_LIBRARIES AND SWIG_FOUND)
+ENDIF (BUILD_PYTHON_WRAPPING AND Python_FOUND AND SWIG_FOUND)
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
/*
- * BatchManager.cxx :
+ * BatchManager.cxx :
*
* Auteur : Ivan DUTKA-MALEN - EDF R&D
* Date : Septembre 2003
// }
BatchManager::BatchManager(const FactBatchManager * parent, const char * host) throw(InvalidArgumentException) : _hostname(host), jobid_map(), _parent(parent)
{
+#ifdef WIN32
+ WSADATA wsaData;
+ WSAStartup(MAKEWORD(2, 2), &wsaData); // Initialize Winsock
+#endif
+
// On verifie que le hostname est correct
- if (!gethostbyname(_hostname.c_str())) { // hostname unknown from network
+ struct hostent* res = gethostbyname(_hostname.c_str());
+
+#ifdef WIN32
+ WSACleanup(); // Finalize Winsock
+#endif
+
+ if (!res) { // hostname unknown from network
string msg = "hostname \"";
msg += _hostname;
msg += "\" unknown from the network";
// {
// // Nothing to do
// }
-
+
// // Methode pour le controle des jobs : suspend un job en file d'attente
// void BatchManager::holdJob(const JobId & jobid)
// {
// Forbid the use of copy constructor and assignment operator
BatchManagerCatalog(const BatchManagerCatalog & orig) {}
- BatchManagerCatalog& operator=(const BatchManagerCatalog & orig) {}
+ BatchManagerCatalog& operator=(const BatchManagerCatalog & orig) { return *this; }
};
virtual ~Couple() {}
// Operateur pour l'affichage sur un stream
- friend std::ostream & operator << (std::ostream & os, const Couple & cp);
+ BATCH_EXPORT friend std::ostream & operator << (std::ostream & os, const Couple & cp);
// Operateur d'affectation
virtual Couple & operator =(const Couple &);
#define _BATCH_Defines_HXX_
#ifdef WIN32
-# if defined BATCH_EXPORTS || defined SalomeBatch_EXPORTS
+# if defined Batch_EXPORTS
# define BATCH_EXPORT __declspec( dllexport )
# else
# define BATCH_EXPORT __declspec( dllimport )
# endif
-# define RM "rm"
-# define RCP "rpc"
-# define RSH "rsh"
#else
# define BATCH_EXPORT
#endif
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
/*
- * GenericException.cxx :
+ * GenericException.cxx :
*
* Auteur : Ivan DUTKA-MALEN - EDF R&D
* Mail : mailto:ivan.dutka-malen@der.edf.fr
*
*/
+#include <iostream>
#include "Batch_GenericException.hxx"
+
using namespace std;
namespace Batch {
+// Operator for writing on a stream
+ostream & operator <<(ostream & os, const GenericException & e)
+{
+ return os << e.type << ": " << e.message;
+}
+
}
const std::string & ch = "undefined") : type(tp), message(ch) {}
};
+ // Operator for writing on a stream
+ BATCH_EXPORT std::ostream & operator <<(std::ostream & os, const GenericException & e);
+
}
#endif
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
/*
- * GenericType.hxx :
+ * GenericType.hxx :
*
* Auteur : Ivan DUTKA-MALEN - EDF R&D
* Date : Septembre 2003
virtual ~GenericType() { _nb--; }
// Operateur pour l'affichage sur un stream
- friend std::ostream & operator << (std::ostream & os, const GenericType & obj);
+ BATCH_EXPORT friend std::ostream & operator << (std::ostream & os, const GenericType & obj);
// Conversion en chaine
virtual std::string affiche() const;
private:
static int _nb; // nombre total d'objets GenericType et al.
-
+
};
}
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
/*
- * Job.hxx :
+ * Job.hxx :
*
* Auteur : Ivan DUTKA-MALEN - EDF R&D
* Date : Septembre 2003
Job(Batch::Environnement env);
Job(Batch::Parametre param, Batch::Environnement env);
virtual ~Job() {}
-
+
// Operateur pour l'affichage sur un stream
- friend std::ostream & operator <<(std::ostream & os, const Job & job);
+ BATCH_EXPORT friend std::ostream & operator <<(std::ostream & os, const Job & job);
// Accesseurs
Batch::Parametre getParametre() const;
void setParametre(const Batch::Parametre &);
-
+
// Accesseurs
Batch::Environnement getEnvironnement() const;
void setEnvironnement(const Batch::Environnement &);
-
+
// Methodes pour l'interfacage avec Python (SWIG)
// TODO : supprimer ces methodes et transferer leur definitions dans SWIG
std::string __str__() const; // SWIG : affichage en Python
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
/*
- * JobInfo.hxx :
+ * JobInfo.hxx :
*
* Auteur : Ivan DUTKA-MALEN - EDF R&D
* Mail : mailto:ivan.dutka-malen@der.edf.fr
JobInfo(const JobInfo & jinfo) : _param(jinfo._param), _env(jinfo._env) {};
// Operateur pour l'affichage sur un stream
- friend std::ostream & operator <<(std::ostream & os, const JobInfo & ji);
+ BATCH_EXPORT friend std::ostream & operator <<(std::ostream & os, const JobInfo & ji);
// Accesseurs
// _CS_gbo Ajout explicite du namespace pour les besoins de swig (mauvaise gestion
// des namespace par swig.
virtual Batch::Parametre getParametre() const;
- virtual Batch::Environnement getEnvironnement() const;
+ virtual Batch::Environnement getEnvironnement() const;
// Methodes pour l'interfacage avec Python (SWIG)
// TODO : supprimer ces methodes et transferer leur definitions dans SWIG
}
// Constructeur par recopie
- Parametre::Parametre(const Parametre & PM)
+ Parametre::Parametre(const Parametre & PM) : map< string, Versatile >()
{
// inutile car l'objet est vierge : il vient d'etre cree
// On efface toute la map
std::string str() const throw(TypeMismatchException);
// Operateur pour l'affichage sur un stream
- friend std::ostream & operator << (std::ostream & os, const Versatile & );
+ BATCH_EXPORT friend std::ostream & operator << (std::ostream & os, const Versatile & );
// Positionnement et recuperation du type de l'element interne
void setType(DiscriminatorType) throw(TypeMismatchException);
// eventually remove any previous result
remove("result.txt");
- // Define the job...
- Job job;
- // ... and its parameters ...
- Parametre p;
- p["EXECUTABLE"] = "./copied-test-script.sh";
- p["NAME"] = "Test_Local_RSH";
- p["WORKDIR"] = TEST_LOCAL_RSH_WORK_DIR;
- p["INFILE"] = Couple("seta.sh", "copied-seta.sh");
- p["INFILE"] += Couple("setb.sh", "copied-setb.sh");
- p["INFILE"] += Couple("test-script.sh", "copied-test-script.sh");
- p["OUTFILE"] = Couple("result.txt", "orig-result.txt");
- p["EXECUTIONHOST"] = TEST_LOCAL_RSH_EXECUTION_HOST;
- job.setParametre(p);
- // ... and its environment
- Environnement e;
- job.setEnvironnement(e);
- cout << job << endl;
-
- // Get the catalog
- BatchManagerCatalog& c = BatchManagerCatalog::getInstance();
-
- // Create a BatchManager of type Local_RSH on localhost
- FactBatchManager * fbm = c("RSH");
- BatchManager * bm = (*fbm)("localhost");
-
- // Submit the job to the BatchManager
- JobId jobid = bm->submitJob(job);
- cout << jobid.__repr__() << endl;
-
- // Wait for the end of the job
- string state = "Unknown";
- while (state != "Done") {
- usleep(10000);
- JobInfo jinfo = jobid.queryJob();
- state = jinfo.getParametre()["STATE"].str();
- }
+ try {
+ // Define the job...
+ Job job;
+ // ... and its parameters ...
+ Parametre p;
+ p["EXECUTABLE"] = "./copied-test-script.sh";
+ p["NAME"] = "Test_Local_RSH";
+ p["WORKDIR"] = TEST_LOCAL_RSH_WORK_DIR;
+ p["INFILE"] = Couple("seta.sh", "copied-seta.sh");
+ p["INFILE"] += Couple("setb.sh", "copied-setb.sh");
+ p["INFILE"] += Couple("test-script.sh", "copied-test-script.sh");
+ p["OUTFILE"] = Couple("result.txt", "orig-result.txt");
+ p["EXECUTIONHOST"] = TEST_LOCAL_RSH_EXECUTION_HOST;
+ job.setParametre(p);
+ // ... and its environment
+ Environnement e;
+ job.setEnvironnement(e);
+ cout << job << endl;
+
+ // Get the catalog
+ BatchManagerCatalog& c = BatchManagerCatalog::getInstance();
+
+ // Create a BatchManager of type Local_RSH on localhost
+ FactBatchManager * fbm = c("RSH");
+ BatchManager * bm = (*fbm)("localhost");
+
+ // Submit the job to the BatchManager
+ JobId jobid = bm->submitJob(job);
+ cout << jobid.__repr__() << endl;
+
+ // Wait for the end of the job
+ string state = "Unknown";
+ for (int i=0 ; i<100 && state != "Done" ; i++) {
+ usleep(100000);
+ Versatile paramState = jobid.queryJob().getParametre()["STATE"];
+ state = (paramState.size() > 0) ? paramState.str() : "Unknown";
+ cout << "Job state is: " << state << endl;
+ }
- cout << "Job " << jobid.__repr__() << " is done" << endl;
+ if (state != "Done") {
+ cerr << "Error: Job not finished after timeout" << endl;
+ return 1;
+ }
+
+ cout << "Job " << jobid.__repr__() << " is done" << endl;
+
+ } catch (GenericException e) {
+ cerr << "Error: " << e << endl;
+ return 1;
+ }
// wait for 5 more seconds for the copy of output files and the cleanup
// (there's no cleaner way to do that yet)
// eventually remove any previous result
remove("result.txt");
- // Define the job...
- Job job;
- // ... and its parameters ...
- Parametre p;
- p["EXECUTABLE"] = "./copied-test-script.sh";
- p["NAME"] = "Test_Local_SH";
- p["WORKDIR"] = "/tmp";
- p["INFILE"] = Couple("seta.sh", "copied-seta.sh");
- p["INFILE"] += Couple("setb.sh", "copied-setb.sh");
- p["INFILE"] += Couple("test-script.sh", "copied-test-script.sh");
- p["OUTFILE"] = Couple("result.txt", "orig-result.txt");
- job.setParametre(p);
- // ... and its environment
- Environnement e;
- job.setEnvironnement(e);
- cout << job << endl;
-
- // Get the catalog
- BatchManagerCatalog& c = BatchManagerCatalog::getInstance();
-
- // Create a BatchManager of type Local_SH on localhost
- FactBatchManager * fbm = c("SH");
- BatchManager * bm = (*fbm)("localhost");
-
- // Submit the job to the BatchManager
- JobId jobid = bm->submitJob(job);
- cout << jobid.__repr__() << endl;
-
- // Wait for the end of the job
- string state = "Unknown";
- while (state != "Done") {
- usleep(10000);
- JobInfo jinfo = jobid.queryJob();
- state = jinfo.getParametre()["STATE"].str();
- }
+ try {
+ // Define the job...
+ Job job;
+ // ... and its parameters ...
+ Parametre p;
+ p["EXECUTABLE"] = "./copied-test-script.sh";
+ p["NAME"] = "Test_Local_SH";
+ p["WORKDIR"] = "/tmp";
+ p["INFILE"] = Couple("seta.sh", "copied-seta.sh");
+ p["INFILE"] += Couple("setb.sh", "copied-setb.sh");
+ p["INFILE"] += Couple("test-script.sh", "copied-test-script.sh");
+ p["OUTFILE"] = Couple("result.txt", "orig-result.txt");
+ job.setParametre(p);
+ // ... and its environment
+ Environnement e;
+ job.setEnvironnement(e);
+ cout << job << endl;
+
+ // Get the catalog
+ BatchManagerCatalog& c = BatchManagerCatalog::getInstance();
+
+ // Create a BatchManager of type Local_SH on localhost
+ FactBatchManager * fbm = c("SH");
+ BatchManager * bm = (*fbm)("localhost");
+
+ // Submit the job to the BatchManager
+ JobId jobid = bm->submitJob(job);
+ cout << jobid.__repr__() << endl;
+
+ // Wait for the end of the job
+ string state = "Unknown";
+ for (int i=0 ; i<10 && state != "Done" ; i++) {
+ usleep(100000);
+ Versatile paramState = jobid.queryJob().getParametre()["STATE"];
+ state = (paramState.size() > 0) ? paramState.str() : "Unknown";
+ cout << "Job state is: " << state << endl;
+ }
- cout << "Job " << jobid.__repr__() << " is done" << endl;
+ if (state != "Done") {
+ cerr << "Error: Job not finished after timeout" << endl;
+ return 1;
+ }
+
+ cout << "Job " << jobid.__repr__() << " is done" << endl;
+
+ } catch (GenericException e) {
+ cerr << "Error: " << e << endl;
+ return 1;
+ }
// wait for 2 more seconds for the copy of output files and the cleanup
// (there's no cleaner way to do that yet)
// eventually remove any previous result
remove("result.txt");
- // Define the job...
- Job job;
- // ... and its parameters ...
- Parametre p;
- p["EXECUTABLE"] = "./copied-test-script.sh";
- p["NAME"] = "Test_Local_SSH";
- p["WORKDIR"] = TEST_LOCAL_SSH_WORK_DIR;
- p["INFILE"] = Couple("seta.sh", "copied-seta.sh");
- p["INFILE"] += Couple("setb.sh", "copied-setb.sh");
- p["INFILE"] += Couple("test-script.sh", "copied-test-script.sh");
- p["OUTFILE"] = Couple("result.txt", "orig-result.txt");
- p["EXECUTIONHOST"] = TEST_LOCAL_SSH_EXECUTION_HOST;
- job.setParametre(p);
- // ... and its environment (SSH_AUTH_SOCK env var is important for ssh agent authentication)
- Environnement e;
- e["SSH_AUTH_SOCK"] = getenv("SSH_AUTH_SOCK");
- job.setEnvironnement(e);
- cout << job << endl;
-
- // Get the catalog
- BatchManagerCatalog& c = BatchManagerCatalog::getInstance();
-
- // Create a BatchManager of type Local_SSH on localhost
- FactBatchManager * fbm = c("SSH");
- BatchManager * bm = (*fbm)("localhost");
-
- // Submit the job to the BatchManager
- JobId jobid = bm->submitJob(job);
- cout << jobid.__repr__() << endl;
-
- // Wait for the end of the job
- string state = "Unknown";
- while (state != "Done") {
- usleep(10000);
- JobInfo jinfo = jobid.queryJob();
- state = jinfo.getParametre()["STATE"].str();
- }
+ try {
+ // Define the job...
+ Job job;
+ // ... and its parameters ...
+ Parametre p;
+ p["EXECUTABLE"] = "./copied-test-script.sh";
+ p["NAME"] = "Test_Local_SSH";
+ p["WORKDIR"] = TEST_LOCAL_SSH_WORK_DIR;
+ p["INFILE"] = Couple("seta.sh", "copied-seta.sh");
+ p["INFILE"] += Couple("setb.sh", "copied-setb.sh");
+ p["INFILE"] += Couple("test-script.sh", "copied-test-script.sh");
+ p["OUTFILE"] = Couple("result.txt", "orig-result.txt");
+ p["EXECUTIONHOST"] = TEST_LOCAL_SSH_EXECUTION_HOST;
+ job.setParametre(p);
+ // ... and its environment (SSH_AUTH_SOCK env var is important for ssh agent authentication)
+ Environnement e;
+ const char * sshAuthSock = getenv("SSH_AUTH_SOCK");
+ if (sshAuthSock != NULL) e["SSH_AUTH_SOCK"] = sshAuthSock;
+ job.setEnvironnement(e);
+ cout << job << endl;
+
+ // Get the catalog
+ BatchManagerCatalog& c = BatchManagerCatalog::getInstance();
+
+ // Create a BatchManager of type Local_SSH on localhost
+ FactBatchManager * fbm = c("SSH");
+ BatchManager * bm = (*fbm)("localhost");
+
+ // Submit the job to the BatchManager
+ JobId jobid = bm->submitJob(job);
+ cout << jobid.__repr__() << endl;
+
+ // Wait for the end of the job
+ string state = "Unknown";
+ for (int i=0 ; i<100 && state != "Done" ; i++) {
+ usleep(100000);
+ Versatile paramState = jobid.queryJob().getParametre()["STATE"];
+ state = (paramState.size() > 0) ? paramState.str() : "Unknown";
+ cout << "Job state is: " << state << endl;
+ }
- cout << "Job " << jobid.__repr__() << " is done" << endl;
+ if (state != "Done") {
+ cerr << "Error: Job not finished after timeout" << endl;
+ return 1;
+ }
+
+ cout << "Job " << jobid.__repr__() << " is done" << endl;
+
+ } catch (GenericException e) {
+ cerr << "Error: " << e << endl;
+ return 1;
+ }
// wait for 5 more seconds for the copy of output files and the cleanup
// (there's no cleaner way to do that yet)
#define TEST_LOCAL_SSH_EXECUTION_HOST "${TEST_LOCAL_SSH_EXECUTION_HOST}"
#define TEST_LOCAL_SSH_WORK_DIR "${TEST_LOCAL_SSH_WORK_DIR}"
+
+#ifdef WIN32
+#define sleep(seconds) Sleep((seconds)*1000)
+#define usleep(useconds) Sleep((useconds)/1000)
+#endif
// Methode pour le controle des jobs : soumet un job au gestionnaire
const JobId BatchManager_ePBS::submitJob(const Job & job)
{
+#ifdef WIN32
+ throw NotYetImplementedException("PBS emulation not supported on Windows platform yet");
+#else
int status;
Parametre params = job.getParametre();
const std::string dirForTmpFiles = params[TMPDIR];
JobId id(this, strjob);
return id;
+#endif //WIN32
}
// Methode pour le controle des jobs : retire un job du gestionnaire
#define TEST_PBS_USER "${TEST_PBS_USER}"
#define TEST_PBS_HOMEDIR "${TEST_PBS_HOMEDIR}"
#define TEST_PBS_QUEUE "${TEST_PBS_QUEUE}"
+
+#ifdef WIN32
+#define sleep(seconds) Sleep((seconds)*1000)
+#define usleep(useconds) Sleep((useconds)/1000)
+#endif
job.setParametre(p);
// ... and its environment (SSH_AUTH_SOCK env var is important for ssh agent authentication)
Environnement e;
- e["SSH_AUTH_SOCK"] = getenv("SSH_AUTH_SOCK");
+ const char * sshAuthSock = getenv("SSH_AUTH_SOCK");
+ if (sshAuthSock != NULL) e["SSH_AUTH_SOCK"] = sshAuthSock;
job.setEnvironnement(e);
cout << job << endl;
}
} catch (GenericException e) {
- cerr << "Batch library exception of type " << e.type << ": " << e.message << endl;
+ cerr << "Error: " << e << endl;
+ return 1;
}
// test the result file
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
/*
- * PyVersatile.hxx :
+ * PyVersatile.hxx :
*
* Auteur : Ivan DUTKA-MALEN - EDF R&D
* Mail : mailto:ivan.dutka-malen@der.edf.fr
#include "Batch_ListIsFullException.hxx"
#include "Batch_InvalidArgumentException.hxx"
+#ifdef WIN32
+# if defined _libBatch_Swig_EXPORTS
+# define BATCH_SWIG_EXPORT __declspec( dllexport )
+# else
+# define BATCH_SWIG_EXPORT __declspec( dllimport )
+# endif
+#else
+# define BATCH_SWIG_EXPORT
+#endif
+
namespace Batch {
- class BATCH_EXPORT PyVersatile : public Versatile
+ class BATCH_SWIG_EXPORT PyVersatile : public Versatile
{
public:
// Constructeur a partir d'un objet Versatile
# Wait for the end of the job
state = 'Unknown'
- while state != 'Done':
+ i=0
+ while state != 'Done' and i<10:
time.sleep(0.1)
+ i+=1
jinfo = jobid.queryJob()
try:
state = jinfo.getParametre()['STATE']
except KeyError:
pass
+ print "State is", state
+
+ if state != "Done":
+ print "Error: Job not finished after timeout"
+ return 1;
print "Job", jobid, "is done"