Added method to create the local directory to import the output files.
#cmakedefine MSVC
#cmakedefine MINGW
-/* SH tools (sh, cp, rm) found on the system */
+/* SH tools (sh, cp, rm, mkdir) found on the system */
#cmakedefine HAS_SH
/* A path to a sh-like command */
/* A path to a cp-like command */
#cmakedefine CP_COMMAND "@CP_COMMAND@"
+/* A path to a mkdir-like command */
+#cmakedefine MKDIR_COMMAND "@MKDIR_COMMAND@"
+
/* RSH tools (rsh, rcp) found on the system */
#cmakedefine HAS_RSH
SET(CPACK_SOURCE_GENERATOR TGZ ZIP)
SET(CPACK_PACKAGE_VERSION_MAJOR 1)
SET(CPACK_PACKAGE_VERSION_MINOR 1)
-SET(CPACK_PACKAGE_VERSION_PATCH 0rc2)
+SET(CPACK_PACKAGE_VERSION_PATCH 0rc3)
SET(CPACK_SOURCE_IGNORE_FILES /\\\\.;/CVS/;~)
SET(CPACK_SOURCE_PACKAGE_FILE_NAME
${PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
FIND_LOCAL_COMMAND_WIN32_DEF(RM_COMMAND rm del)
FIND_LOCAL_COMMAND(SH_COMMAND sh cmd.exe)
FIND_LOCAL_COMMAND_WIN32_DEF(CP_COMMAND cp copy)
+FIND_LOCAL_COMMAND_WIN32_DEF(MKDIR_COMMAND mkdir mkdir)
FIND_LOCAL_COMMAND(RSH_COMMAND rsh rsh)
FIND_LOCAL_COMMAND(RCP_COMMAND rcp rcp)
FIND_LOCAL_COMMAND(SSH_COMMAND ssh plink)
FIND_LOCAL_COMMAND(SCP_COMMAND scp pscp)
-EVAL (HAS_SH SH_COMMAND AND CP_COMMAND AND RM_COMMAND)
+EVAL (HAS_SH SH_COMMAND AND CP_COMMAND AND RM_COMMAND AND MKDIR_COMMAND)
EVAL (HAS_RSH RSH_COMMAND AND RCP_COMMAND)
EVAL (HAS_SSH SSH_COMMAND AND SCP_COMMAND)
Versatile::iterator Vit;
_username = string(params[USER]);
- string subCommand = string("mkdir -p ") + string(params[TMPDIR]) + string("/logs");
- string command = _protocol.getExecCommand(subCommand, _hostname, _username);
- cerr << command.c_str() << endl;
- status = system(command.c_str());
+ status = _protocol.makeDirectory(string(params[TMPDIR]) + "/logs", _hostname, _username);
if(status) {
std::ostringstream oss;
oss << status;
#ifdef WIN32
// On Windows, we make the remote file executable afterward because
// pscp does not preserve access permissions on files
- subCommand = string("chmod u+x ") + string(params[TMPDIR]) + "/" +
- string(params[EXECUTABLE]);
- command = _protocol.getExecCommand(subCommand, _hostname, _username);
+ string subCommand = string("chmod u+x ") + string(params[TMPDIR]) + "/" +
+ string(params[EXECUTABLE]);
+ string command = _protocol.getExecCommand(subCommand, _hostname, _username);
cerr << command.c_str() << endl;
status = system(command.c_str());
if(status) {
Versatile::iterator Vit;
_username = string(params[USER]);
+ // Create local result directory
+ int status = CommunicationProtocol::getInstance(SH).makeDirectory(directory, "", "");
+ if (status) {
+ string mess("Directory creation failed. Status is :");
+ ostringstream status_str;
+ status_str << status;
+ mess += status_str.str();
+ cerr << mess << endl;
+ }
+
for(Vit=V.begin(); Vit!=V.end(); Vit++) {
CoupleType cpt = *static_cast< CoupleType * >(*Vit);
Couple outputFile = cpt;
- int status = _protocol.copyFile(outputFile.getRemote(), _hostname, _username,
- directory, "", "");
+ status = _protocol.copyFile(outputFile.getRemote(), _hostname, _username,
+ directory, "", "");
if (status) {
// Try to get what we can (logs files)
// throw BatchException("Error of connection on remote host");
}
// Copy logs
- int status = _protocol.copyFile(string(params[TMPDIR]) + string("/logs"), _hostname, _username,
- directory, "", "");
+ status = _protocol.copyFile(string(params[TMPDIR]) + string("/logs"), _hostname, _username,
+ directory, "", "");
if (status) {
std::string mess("Copy logs directory failed ! status is :");
ostringstream status_str;
return string("rm ") + path;
}
+ string CommunicationProtocol::getMakeDirectorySubCommand(const string & path) const
+ {
+ return string("mkdir -p ") + path;
+ }
+
int CommunicationProtocol::removeFile(const std::string & path,
const std::string & host,
const std::string & user) const
return status;
}
+ int CommunicationProtocol::makeDirectory(const std::string & path,
+ const std::string & host,
+ const std::string & user) const
+ {
+ string command = getExecCommand(getMakeDirectorySubCommand(path), host, user);
+ cout << command.c_str() << endl;
+ int status = system(command.c_str());
+ return status;
+ }
+
string CommunicationProtocol::commandStringFromArgs(const vector<string> & commandArgs) const
{
string commandStr;
const std::string & host,
const std::string & user) const;
+ virtual int makeDirectory(const std::string & path,
+ const std::string & host,
+ const std::string & user) const;
+
protected:
virtual std::vector<std::string> getCopyCommandArgs(const std::string & sourcePath,
virtual std::string getRemoveSubCommand(const std::string & path) const;
+ virtual std::string getMakeDirectorySubCommand(const std::string & path) const;
+
std::string commandStringFromArgs(const std::vector<std::string> & args) const;
};
string CommunicationProtocolSH::getRemoveSubCommand(const string & path) const
{
- return string(RM_COMMAND) + " " + path;
+ return string(RM_COMMAND) + " " + fixPath(path);
+ }
+
+ string CommunicationProtocolSH::getMakeDirectorySubCommand(const string & path) const
+ {
+ string subCommand = MKDIR_COMMAND;
+#ifndef WIN32
+ subCommand += " -p";
+#endif
+ subCommand += " " + fixPath(path);
+ return subCommand;
}
}
const std::string & destinationHost,
const std::string & destinationUser) const;
+ protected:
+
std::string getRemoveSubCommand(const std::string & path) const;
- protected:
+ std::string getMakeDirectorySubCommand(const std::string & path) const;
std::string fixPath(const std::string & path) const;
if( edt > 0 )
tempOutputFile << "#BSUB -W " << getWallTime(edt) << endl ;
if( mem > 0 )
- tempOutputFile << "#BSUB -M " << mem << endl ;
+ tempOutputFile << "#BSUB -M " << mem*1024 << endl ;
tempOutputFile << "#BSUB -n " << nbproc << endl ;
size_t pos = workDir.find("$HOME");
string baseDir;
if( edt > 0 )
tempOutputFile << "#PBS -l walltime=" << edt*60 << endl;
if( mem > 0 )
- tempOutputFile << "#PBS -l mem=" << mem << "kb" << endl;
+ tempOutputFile << "#PBS -l mem=" << mem << "MB" << endl;
tempOutputFile << "#PBS -o " << workDir << "/logs/output.log." << rootNameToExecute << endl;
tempOutputFile << "#PBS -e " << workDir << "/logs/error.log." << rootNameToExecute << endl;
p[USER] = user;
p[NBPROC] = 1;
p[MAXWALLTIME] = 1;
- p[MAXRAMSIZE] = 1000;
+ p[MAXRAMSIZE] = 1;
p[HOMEDIR] = homedir;
p[QUEUE] = queue;
job.setParametre(p);
if (state == FINISHED || state == FAILED) {
cout << "Job " << jobid.__repr__() << " is done" << endl;
- bm->importOutputFiles(job, ".");
+ bm->importOutputFiles(job, "resultdir/seconddirname");
} else {
cerr << "Timeout while executing job" << endl;
return 1;
// test the result file
try {
SimpleParser resultParser;
- resultParser.parse("result.txt");
+ resultParser.parse("resultdir/seconddirname/result.txt");
cout << "Result:" << endl << resultParser;
const string & envvar = resultParser.getValue("MYENVVAR");
int result = resultParser.getValueAsInt("c");