From b3ce786ac0e1f67226a7e559f3530adf525c6e25 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Thu, 19 Feb 2015 07:44:05 +0000 Subject: [PATCH] clarify exe vs. args + make OnelabRunClient treat exe as full command line --- Common/GmshMessage.cpp | 8 ++++---- Common/OS.cpp | 11 ++++++----- Common/OS.h | 3 ++- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Common/GmshMessage.cpp b/Common/GmshMessage.cpp index 937facdfdf..39eb8802ad 100644 --- a/Common/GmshMessage.cpp +++ b/Common/GmshMessage.cpp @@ -1183,7 +1183,7 @@ void Msg::ImportPhysicalsAsOnelabRegions() #endif } -void Msg::RunOnelabClient(const std::string &name, const std::string &exe) +void Msg::RunOnelabClient(const std::string &name, const std::string &command) { #if defined(HAVE_ONELAB) && !defined(HAVE_ONELAB2) onelab::server::citer it = onelab::server::instance()->findClient(name); @@ -1192,7 +1192,7 @@ void Msg::RunOnelabClient(const std::string &name, const std::string &exe) client = it->second; } else{ - if(exe.empty()){ + if(command.empty()){ Msg::Error("Unknown ONELAB client `%s'", name.c_str()); return; } @@ -1202,8 +1202,8 @@ void Msg::RunOnelabClient(const std::string &name, const std::string &exe) onelab::server::instance()->set(o); #if defined(HAVE_FLTK) Msg::Info("Creating new ONELAB client `%s' (%s)", name.c_str(), - exe.c_str()); - client = new gmshLocalNetworkClient(name, exe); + command.c_str()); + client = new gmshLocalNetworkClient(name, command, "", true); client->run(); #else Msg::Error("Cannot create ONELAB client without FLTK"); diff --git a/Common/OS.cpp b/Common/OS.cpp index 246f8d23b8..380fb481f0 100644 --- a/Common/OS.cpp +++ b/Common/OS.cpp @@ -380,7 +380,8 @@ int KillProcess(int pid) return 1; } -int SystemCallExe(const std::string &exe, const std::string &args, bool blocking) +int SystemCallExe(const std::string &exe, const std::string &argsOrCommand, + bool blocking) { // do we try to run a .py script, .m script or an .exe? std::vector<std::string> split = SplitFileName(exe); @@ -398,17 +399,17 @@ int SystemCallExe(const std::string &exe, const std::string &args, bool blocking std::string command; if(exe.size()){ command.append("\"" + exe + "\""); // allows exe with white space - if(args.size()) command.append(" "); + if(argsOrCommand.size()) command.append(" "); } - command.append(args); + command.append(argsOrCommand); #if defined(WIN32) && !defined(__CYGWIN__) if(isPython || isOctave){ Msg::Info("Shell opening '%s' with arguments '%s'", exe.c_str(), - args.c_str()); + argsOrCommand.c_str()); setwbuf(0, "open"); setwbuf(1, exe.c_str()); - setwbuf(2, args.c_str()); + setwbuf(2, argsOrCommand.c_str()); ShellExecuteW(NULL, wbuf[0], wbuf[1], wbuf[2], NULL, 0); } else{ diff --git a/Common/OS.h b/Common/OS.h index 808f56fba2..115415e853 100644 --- a/Common/OS.h +++ b/Common/OS.h @@ -25,7 +25,8 @@ int KillProcess(int pid); int CreateSingleDir(const std::string &dirName); void CreatePath(const std::string &fullPath); int SystemCall(const std::string &command, bool blocking=false); -int SystemCallExe(const std::string &exe, const std::string &args, bool blocking=false); +int SystemCallExe(const std::string &exe, const std::string &argsOrCommand, + bool blocking=false); std::string GetCurrentWorkdir(); void RedirectIOToConsole(); FILE *Fopen(const char* f, const char *mode); -- GitLab