diff --git a/contrib/onelab/OnelabClients.cpp b/contrib/onelab/OnelabClients.cpp index 1f86747b4897b8c96d1055d30be40765633540e0..f78cedf442419084bd1c049b3b980b8a8021b4a4 100644 --- a/contrib/onelab/OnelabClients.cpp +++ b/contrib/onelab/OnelabClients.cpp @@ -18,40 +18,6 @@ class onelabMetaModelServer : public GmshServer{ : GmshServer(), _client(client) {} ~onelabMetaModelServer(){} -// int NonBlockingSystemCall(const char *command) -// { -// #if defined(WIN32) -// STARTUPINFO suInfo; -// PROCESS_INFORMATION prInfo; -// memset(&suInfo, 0, sizeof(suInfo)); -// suInfo.cb = sizeof(suInfo); -// std::string cmd(command); -// OLMsg::Info("Calling <%s>", cmd.c_str()); -// // DETACHED_PROCESS removes the console (useful if the program to launch is -// // a console-mode exe) -// CreateProcess(NULL,(char *)cmd.c_str(), NULL, NULL, FALSE, -// NORMAL_PRIORITY_CLASS|DETACHED_PROCESS, NULL, NULL, -// &suInfo, &prInfo); -// return 0; -// #else -// if(!system(NULL)) { -// OLMsg::Error("Could not find /bin/sh: aborting system call"); -// return 1; -// } -// std::string cmd(command); -// size_t pos; -// if((pos=cmd.find("incomp_ssh ")) != std::string::npos){ -// cmd.assign(cmd.substr(pos+7)); // remove "incomp_" -// cmd.append(" & '"); -// } -// else -// cmd.append(" & "); - -// OLMsg::Info("Calling <%s>", cmd.c_str()); -// return system(cmd.c_str()); -// #endif -// }// non blocking - int NonBlockingSystemCall(const char *str){ return SystemCall(str); } int NonBlockingWait(int socket, double waitint, double timeout) { @@ -397,15 +363,11 @@ const bool localSolverClient::getList(const std::string type, std::vector<std::s return false; } - -/* -si cmd est un path, vérifier la présence du fichier -sinon faire un which (n'existe pas sous WIN) - */ bool localSolverClient::checkCommandLine(){ + bool success=true; OLMsg::Info("Check command line <%s> for client <%s>", getCommandLine().c_str(), getName().c_str()); - if(!isActive()) return true; + if(!isActive()) return success; if(getCommandLine().empty()){ if(OLMsg::hasGmsh) { @@ -421,36 +383,41 @@ bool localSolverClient::checkCommandLine(){ } } else{ - if(isNative()){ + if(isNative()){ // check done by initializing of the client setAction("initialize"); if(!run()){ // initializes native clients, false otherwise OLMsg::Error("Invalid commandline <%s> for client <%s>", FixExecPath(getCommandLine()).c_str(), getName().c_str()); - return false; + success=false; } } - else{ + else{ // check whether the executable exists as a file std::string cmd,commandLine; char cbuf [1024]; FILE *fp; commandLine.assign(FixExecPath(getCommandLine())); #if !defined(WIN32) + // resolve a possible link or alias cmd.assign("which " + commandLine); fp = POPEN(cmd.c_str(), "r"); if(fgets(cbuf, 1024, fp) == NULL){ OLMsg::Error("The executable <%s> does not exist", commandLine.c_str()); PCLOSE(fp); - return false; + success=false; } - else - commandLine.assign(cbuf); + else + commandLine.assign(sanitizeString(cbuf,"\n")); PCLOSE(fp); #endif - return checkIfPresent(sanitizeString(commandLine,"\n")); + success=checkIfPresent(commandLine); } } - return true; + if(success) + OLMsg::SetOnelabString(getName()+"/CommandLine",getCommandLine(),false); + else + setCommandLine(""); + return success; } bool localSolverClient::buildRmCommand(std::string &cmd){ @@ -1051,6 +1018,7 @@ void RemoteEncapsulatedClient::compute(){ // ONELAB additional TOOLS (no access to server in tools) // options for 'onelab_client' +/* int getOptions(int argc, char *argv[], parseMode &todo, std::string &commandLine, std::string &caseName, std::string &clientName, std::string &sockName){ commandLine=argv[0]; @@ -1097,6 +1065,7 @@ int getOptions(int argc, char *argv[], parseMode &todo, std::string &commandLine } return(1); } +*/ std::string itoa(const int i){ std::ostringstream tmp; diff --git a/contrib/onelab/OnelabClients.h b/contrib/onelab/OnelabClients.h index 0bed40f6f90aa726090d8ff01fc8af75e738bf01..ca4a67187ad0a88a2e9ae18fdcbaa94f6d388784 100644 --- a/contrib/onelab/OnelabClients.h +++ b/contrib/onelab/OnelabClients.h @@ -33,7 +33,7 @@ static std::string whichCmd("which "); #endif // TOOLS -int getOptions(int argc, char *argv[], parseMode &todo, std::string &commandLine, std::string &caseName, std::string &clientName, std::string &sockName); +//int getOptions(int argc, char *argv[], parseMode &todo, std::string &commandLine, std::string &caseName, std::string &clientName, std::string &sockName); std::string itoa(const int i); std::string ftoa(const double x); bool checkIfPresent(std::string fileName); diff --git a/contrib/onelab/OnelabParser.cpp b/contrib/onelab/OnelabParser.cpp index 994c239b5551b4d0c8d76848c1495f109b0b7623..25aabab2ac9e37f9a6889acc1ceafced8f9b27e4 100644 --- a/contrib/onelab/OnelabParser.cpp +++ b/contrib/onelab/OnelabParser.cpp @@ -1345,7 +1345,7 @@ void MetaModel::client_sentence(const std::string &name, onelab::string str; str.setName(name + "/CommandLine"); str.setKind("file"); - str.setVisible(cmdl.empty()); + //str.setVisible(cmdl.empty()); str.setAttribute("Highlight","Ivory"); set(str); } @@ -1483,7 +1483,7 @@ void MetaModel::client_sentence(const std::string &name, } } } - else if(isTodo(COMPUTE)){ + else if(isTodo(COMPUTE) && !OLMsg::GetErrorCount()){ std::vector<std::string> choices; for(unsigned int i = 0; i < arguments.size(); i++){ std::string str=resolveGetVal(arguments[i]); @@ -1498,20 +1498,10 @@ void MetaModel::client_sentence(const std::string &name, OLMsg::Error("Wrong number of arguments <%d> for <%s>", arguments.size(), action.c_str()); } - // else if(!action.compare("check")){ - // localSolverClient *c; - // if((c=findClientByName(name))){ - // c->checkCommandLine(); - // c->analyze(); - // } - // else - // OLMsg::Error("Unknown client <%s>", name.c_str()); - // } else if(!action.compare("alwaysCompute")){ if(isTodo(ANALYZE)){ localSolverClient *c; if((c=findClientByName(name))){ - //c->checkCommandLine(); c->compute(); onelab::server::instance()->setChanged(false, c->getName()); } @@ -1520,7 +1510,7 @@ void MetaModel::client_sentence(const std::string &name, } } else if(!action.compare("merge")){ - if(isTodo(COMPUTE)){ + if(isTodo(COMPUTE) && !OLMsg::GetErrorCount()){ std::vector<std::string> choices; for(unsigned int i = 0; i < arguments.size(); i++){ choices.push_back(resolveGetVal(arguments[i]));