X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FLauncher%2FLauncher_Job.cxx;h=0541c5cd0d7e0bd2fe208227673547a7d4cd94c7;hb=f2b4b2e1b8983a9fa514e2355ebaff4618cd4eea;hp=e98e0f204ae4f1be22be19acc1f64f2b049b9c33;hpb=7d12ccca1bde073e5405a864eb5e7f7ed2f4ced3;p=modules%2Fyacs.git diff --git a/src/Launcher/Launcher_Job.cxx b/src/Launcher/Launcher_Job.cxx index e98e0f204..0541c5cd0 100644 --- a/src/Launcher/Launcher_Job.cxx +++ b/src/Launcher/Launcher_Job.cxx @@ -29,6 +29,11 @@ #endif #include +#ifdef WIN32 + static const char SEPARATOR = '\\'; +#else + static const char SEPARATOR = '/'; +#endif Launcher::Job::Job() { @@ -48,6 +53,7 @@ Launcher::Job::Job() _maximum_duration = ""; _maximum_duration_in_second = -1; _queue = ""; + _partition = ""; _job_type = ""; _exclusive = false; _mem_per_cpu = 0; @@ -180,7 +186,11 @@ Launcher::Job::setResourceDefinition(const ParserResourcesType & resource_defini std::string user_name = ""; if (resource_definition.UserName == "") { +#ifndef WIN32 user_name = getenv("USER"); +#else + user_name = getenv("USERNAME"); +#endif if (user_name == "") user_name = getenv("LOGNAME"); if (user_name == "") @@ -213,7 +223,7 @@ Launcher::Job::setJobFile(const std::string & job_file) } _job_file = job_file; - std::string::size_type p1 = _job_file.find_last_of("/"); + std::string::size_type p1 = _job_file.find_last_of(SEPARATOR); std::string::size_type p2 = _job_file.find_last_of("."); _job_file_name_complete = _job_file.substr(p1+1); _job_file_name = _job_file.substr(p1+1,p2-p1-1); @@ -307,6 +317,12 @@ Launcher::Job::setQueue(const std::string & queue) _queue = queue; } +void +Launcher::Job::setPartition(const std::string & partition) +{ + _partition = partition; +} + void Launcher::Job::setExclusive(bool exclusive) { @@ -408,6 +424,12 @@ Launcher::Job::getQueue() const return _queue; } +std::string +Launcher::Job::getPartition() const +{ + return _partition; +} + bool Launcher::Job::getExclusive() const { @@ -539,7 +561,7 @@ Launcher::Job::getLaunchDate() const launch_date[i] == ':' || launch_date[i] == ' ') launch_date[i] = '_'; - launch_date.erase(--launch_date.end()); // Last caracter is a \n + launch_date.erase(--launch_date.end()); // Last character is a \n return launch_date; } @@ -585,6 +607,9 @@ Launcher::Job::common_job_params() params[Batch::NBPROC] = _resource_required_params.nb_proc; params[Batch::NBPROCPERNODE] = _resource_required_params.nb_proc_per_node; + if(_resource_required_params.nb_node > 0) + params[Batch::NBNODE] = _resource_required_params.nb_node; + // Memory in megabytes if (_resource_required_params.mem_mb > 0) { @@ -613,7 +638,11 @@ Launcher::Job::common_job_params() } else { +#ifndef WIN32 _work_directory = std::string("/$HOME/Batch/workdir_"); +#else + _work_directory = std::string("%USERPROFILE%\\Batch\\workdir_"); +#endif _work_directory += date; } } @@ -632,8 +661,11 @@ Launcher::Job::common_job_params() // If result_directory is not defined, we use HOME environnement if (_result_directory == "") +#ifndef WIN32 _result_directory = getenv("HOME"); - +#else + _result_directory = getenv("USERPROFILE"); +#endif // _in_files std::list in_files(_in_files); in_files.push_back(_job_file); @@ -647,18 +679,26 @@ Launcher::Job::common_job_params() // local file -> If file is not an absolute path, we apply _local_directory std::string local_file; +#ifndef WIN32 if (file.substr(0, 1) == std::string("/")) +#else + // On Windows, absolute paths may begin with something like "C:" + if (file.substr(1, 1) == std::string(":")) +#endif + local_file = file; + else if (file.substr(0, 1) == std::string("-")) // using rsync options local_file = file; else #ifndef WIN32 - local_file = _local_directory + "/" + file; + // '/./' is used by rsync to find the root of the relative path + // /a/b/./c/f -> _working_directory/c/f + local_file = _local_directory + "/./" + file; #else - local_file = file; + local_file = _local_directory + SEPARATOR + file; #endif // remote file -> get only file name from in_files - size_t found = file.find_last_of("/"); - std::string remote_file = _work_directory + "/" + file.substr(found+1); + std::string remote_file = _work_directory + "/"; params[Batch::INFILE] += Batch::Couple(local_file, remote_file); } @@ -676,10 +716,16 @@ Launcher::Job::common_job_params() size_t found = file.find_last_of("/"); local_file = file.substr(found+1); } + else if (file.substr(0, 1) == std::string("-")) // using rsync options + { + remote_file = file; + local_file = ""; + } else { - remote_file = _work_directory + "/" + file; - local_file = file; + // '/./' is used by rsync to find the root of the relative path + remote_file = _work_directory + "/./" + file; + local_file = ""; } params[Batch::OUTFILE] += Batch::Couple(local_file, remote_file); @@ -693,6 +739,10 @@ Launcher::Job::common_job_params() if (_queue != "") params[Batch::QUEUE] = _queue; + // Partition + if (_partition != "") + params[Batch::PARTITION] = _partition; + // Exclusive if (getExclusive()) params[Batch::EXCLUSIVE] = true;