return rtn;
}
+long Launcher_cpp::getMaximumDurationInSecond(int job_id)
+{
+ Launcher::Job *job = findJob(job_id);
+ return job->getMaximumDurationInSecond();
+}
+
//=============================================================================
/*!
* Remove the job - into the Launcher and its batch manager
"(libBatch was not present at compilation time)");
}
+long Launcher_cpp::getMaximumDurationInSecond(int job_id)
+{
+ LAUNCHER_INFOS("Launcher compiled without LIBBATCH - cannot get job dump state!!!");
+ throw LauncherException("Method Launcher_cpp::getMaximumDurationInSecond is not available "
+ "(libBatch was not present at compilation time)");
+}
+
void
Launcher_cpp::removeJob(int job_id)
{
void clearJobWorkingDir(int job_id);
bool getJobDumpState(int job_id, std::string directory);
bool getJobWorkFile(int job_id, std::string work_file, std::string directory);
+ long getMaximumDurationInSecond(int job_id);
void stopJob(int job_id);
void removeJob(int job_id);
std::string dumpJob(int job_id);
long
Launcher::Job::convertMaximumDuration(const std::string & edt)
{
- long hh, mm, ret;
+ long dd(0), hh(0), mm(0);
if( edt.size() == 0 )
return -1;
- std::string::size_type pos = edt.find(":");
- std::string h = edt.substr(0,pos);
- std::string m = edt.substr(pos+1,edt.size()-pos+1);
+ std::string remain( edt );
+
+ auto pos_day = edt.find('-');
+ if( pos_day != std::string::npos)
+ {
+ std::string d = edt.substr(0,pos_day);
+ if(pos_day == edt.size()-1)
+ return -1;
+ remain = edt.substr(pos_day+1);
+ std::istringstream issd(d);
+ issd >> dd;
+ }
+ std::string::size_type pos = remain.find(':');
+ std::string h = remain.substr(0,pos);
+ std::string m = remain.substr(pos+1,remain.size()-pos+1);
std::istringstream issh(h);
issh >> hh;
std::istringstream issm(m);
issm >> mm;
- ret = hh*60 + mm;
- ret = ret * 60;
-
- return ret;
+ long ret = dd*60*24 + hh*60 + mm;
+ return 60*ret;
}
std::string
const std::list<std::string> & get_in_files() const;
const std::list<std::string> & get_out_files() const;
std::string getMaximumDuration() const;
+ long getMaximumDurationInSecond() const { return this->_maximum_duration_in_second; }
resourceParams getResourceRequiredParams() const;
std::string getQueue() const;
std::string getPartition() const;
void clearJobWorkingDir(int job_id);
bool getJobDumpState(int job_id, std::string directory);
bool getJobWorkFile(int job_id, std::string work_file, std::string directory);
+ long getMaximumDurationInSecond(int job_id);
void stopJob(int job_id);
void removeJob(int job_id);
std::string dumpJob(int job_id);
self.verifyFile(os.path.join(mydir, "copie", "copie.txt"),
"to be copied")
pass
+
+
+ def test_maximum_duration_management_0(self):
+ """
+ [EDF30356] : Check correct conversion of format DD-HH:MM into second before sending it to libbatch
+ """
+ def EndUserMaxDurationToSecond( endUserEntry ):
+ params = pylauncher.JobParameters_cpp()
+ params.maximum_duration = endUserEntry
+ launcher = pylauncher.Launcher_cpp()
+ params.job_type = "command_salome"
+ params.resource_required = pylauncher.resourceParams()
+ params.job_file = "test.py"
+ params.resource_required.nb_proc = 1
+ jobId = launcher.createJob( params )
+ return launcher.getMaximumDurationInSecond( jobId )
+
+ self.assertEqual( EndUserMaxDurationToSecond( "15:10" ), 54600)
+ self.assertEqual( EndUserMaxDurationToSecond( "0-02:10" ), 7800)
+ self.assertEqual( EndUserMaxDurationToSecond( "0-00:59" ), 3540)
+ self.assertEqual( EndUserMaxDurationToSecond( "1-00:00" ), 86400)
+ self.assertEqual( EndUserMaxDurationToSecond( "2-00:00" ), 172800)
+ self.assertEqual( EndUserMaxDurationToSecond( "2-03:04" ), 183840)
+
pass
pass