1 // Copyright (C) 2012-2015 INRIA
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
26 #include "Constants.hxx"
27 #include "Parametre.hxx"
28 #include "Environnement.hxx"
29 #include "RunTimeException.hxx"
30 #include "APIInternalFailureException.hxx"
31 #include "JobInfo_COORM.hxx"
38 JobInfo_COORM::JobInfo_COORM(const std::string & id, const std::string & queryOutput) : JobInfo()
43 istringstream logfile(queryOutput);
45 string sline, state, assigned_hostnames;
49 while (getline(logfile, sline) && sline != "")
51 vector<string> tokens;
53 JobInfo::Tokenize(sline, tokens, "= ");
55 if (tokens[0] == "state")
60 if (tokens[0] == "assigned_hostnames")
62 assigned_hostnames = tokens[1];
66 _param[ASSIGNEDHOSTNAMES] = assigned_hostnames;
68 if (state == "FINISHED")
71 _param[STATE] = FINISHED;
73 else if (state == "STARTED")
76 _param[STATE] = RUNNING;
78 else if (state == "WAITING")
81 _param[STATE] = QUEUED;
83 else if (state == "SUBMITTED")
86 _param[STATE] = CREATED;
88 else if (state == "KILLED")
91 _param[STATE] = FAILED;
95 cerr << "Unknown job state code: " << state << endl;
100 throw RunTimeException("Error of connection on remote host");
105 JobInfo_COORM::~JobInfo_COORM()
110 // Convertit une date HH:MM:SS en secondes
111 long JobInfo_COORM::HMStoLong(const string & s)
115 sscanf( s.c_str(), "%ld:%ld:%ld", &hour, &min, &sec);
116 return ( ( ( hour * 60L ) + min ) * 60L ) + sec;
119 // Methode pour l'interfacage avec Python (SWIG) : affichage en Python
120 string JobInfo_COORM::__str__() const
123 sst << "<JobInfo_eCOORM (" << this << ") :" << endl;
124 sst << " ID = " <<_param[ID] << endl;
125 sst << " STATE = " <<_param[STATE] << endl;