1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 * JobInfo_LSF.cxx : emulation of LSF client
25 * Auteur : Bernard SECHER - CEA DEN
26 * Mail : mailto:bernard.secher@cea.fr
27 * Date : Thu Apr 24 10:17:22 2008
35 #include <Constants.hxx>
36 #include "JobInfo_LSF.hxx"
44 JobInfo_LSF::JobInfo_LSF(int id, const std::string & queryOutput) : JobInfo()
49 _param[ID] = oss.str();
53 istringstream fp(queryOutput);
56 // On some batch managers, the job is deleted soon after it is finished,
57 // so we have to consider that an unknown job (empty file) is a finished
58 // one, even if it is not always true.
60 _param[STATE] = FINISHED;
62 string sjobid, username, status;
67 if (status == "PEND") { // Pending
68 _param[STATE] = QUEUED;
69 } else if (status == "PSUSP") { // Suspended while pending
70 _param[STATE] = PAUSED;
71 } else if (status == "RUN") { // Running
72 _param[STATE] = RUNNING;
73 } else if (status == "USUSP") { // Suspended while running
74 _param[STATE] = PAUSED;
75 } else if (status == "SSUSP") { // Suspended by LSF
76 _param[STATE] = PAUSED;
77 } else if (status == "DONE") { // Finished successfully
78 _param[STATE] = FINISHED;
79 } else if (status == "EXIT") { // Finished in error
80 _param[STATE] = FAILED;
81 } else if (status == "UNKWN") { // Lost contact
82 _param[STATE] = FAILED;
83 } else if (status == "ZOMBI") { // Zombie
84 _param[STATE] = FAILED;
86 LOG("Unknown job state code: " << status);
89 if( status.find("RUN") != string::npos)
94 // Teste si un job est present en machine
95 bool JobInfo_LSF::isRunning() const
102 JobInfo_LSF::~JobInfo_LSF()
107 // Convertit une date HH:MM:SS en secondes
108 long JobInfo_LSF::HMStoLong(const string & s)
112 sscanf( s.c_str(), "%ld:%ld:%ld", &hour, &min, &sec);
113 return ( ( ( hour * 60L ) + min ) * 60L ) + sec;
116 // Methode pour l'interfacage avec Python (SWIG) : affichage en Python
117 string JobInfo_LSF::__str__() const
120 sst << "<JobInfo_LSF (" << this << ") :" << endl;
121 sst << " ID = " <<_param[ID] << endl;
122 sst << " STATE = " <<_param[STATE] << endl;