GUI_MODE = guiMode;
}
-std::string BASICS_EXPORT getIOROfEmbeddedNS()
+std::string getIOROfEmbeddedNS()
{
return IOR_OF_EMBEDDED_NS;
}
-void BASICS_EXPORT setIOROfEmbeddedNS(const std::string& ior)
+void setIOROfEmbeddedNS(const std::string& ior)
{
IOR_OF_EMBEDDED_NS = ior;
}
+
+#include <iostream>
+
+/*!
+ * Callable from Python in case if sys.stdout is not connected to tty
+ */
+void WriteInStdout(const std::string& msg)
+{
+ std::cout << msg << std::endl << std::flush;
+}
+
+/*!
+ * Callable from Python in case if sys.stdout is not connected to tty
+ */
+void WriteInStderr(const std::string& msg)
+{
+ std::cerr << msg << std::endl << std::flush;
+}
std::string BASICS_EXPORT getIOROfEmbeddedNS();
void BASICS_EXPORT setIOROfEmbeddedNS(const std::string& ior);
+
+void BASICS_EXPORT WriteInStdout(const std::string& msg);
+void BASICS_EXPORT WriteInStderr(const std::string& msg);
%{
#include "KernelBasis.hxx"
#include "HeatMarcel.hxx"
+#include "libSALOMELog.hxx"
using namespace SALOME;
%}
double GetTimeAdjustmentCst();
+bool VerbosityActivated();
+
+void SetVerbosityActivated(bool flag);
+
+void WriteInStdout(const std::string& msg);
+
+void WriteInStderr(const std::string& msg);
+
+
%inline
{
PyObject *HeatMarcelSwig(double timeAjustment, unsigned int nbThreads = 0)
#include <string>
#include <iostream>
+enum class VerbosityMode { undefined, nolog, withlog };
+
+static VerbosityMode isActivated = VerbosityMode::undefined;
+
namespace SALOME
{
bool VerbosityActivated()
{
- auto isEnvVarSet = []() -> bool
+ auto isEnvVarSet = []() -> VerbosityMode
{
const char* envVar = std::getenv("SALOME_VERBOSE");
try
{
const long long numValue = std::stoll(envVar);
- return numValue > 0;
+ return numValue > 0?VerbosityMode::withlog:VerbosityMode::nolog;
}
catch(const std::exception& e)
{
}
}
- return false;
+ return VerbosityMode::nolog;
};
- static const bool isActivated = isEnvVarSet();
- return isActivated;
+ if(isActivated == VerbosityMode::undefined)
+ isActivated = isEnvVarSet();
+ return isActivated == VerbosityMode::withlog;
+ }
+
+ void SetVerbosityActivated(bool flag)
+ {
+ isActivated = flag ? VerbosityMode::withlog:VerbosityMode::nolog;
}
}
namespace SALOME
{
bool BASICS_EXPORT VerbosityActivated();
+ void BASICS_EXPORT SetVerbosityActivated(bool);
}
MESSAGE("[GiveContainer] Try to launch a new container on " << resource_selected);
// if a parallel container is launched in batch job, command is: "mpirun -np nbproc -machinefile nodesfile SALOME_MPIContainer"
if( GetenvThreadSafe("LIBBATCH_NODEFILE") != NULL && params.isMPI )
+ {
command = BuildCommandToLaunchLocalContainer(params, machFile, container_exe, tmpFileName);
+ MESSAGE("[LaunchContainer] LIBBATCH_NODEFILE : \"" << command << "\"");
+ }
// if a container is launched on localhost, command is "SALOME_Container" or "mpirun -np nbproc SALOME_MPIContainer"
else if(hostname == Kernel_Utils::GetHostname())
+ {
command = BuildCommandToLaunchLocalContainer(params, machFile, container_exe, tmpFileName);
+ MESSAGE("[LaunchContainer] hostname local : \"" << command << "\"");
+ }
// if a container is launched in remote mode, command is "ssh resource_selected SALOME_Container" or "ssh resource_selected mpirun -np nbproc SALOME_MPIContainer"
else
+ {
command = BuildCommandToLaunchRemoteContainer(resource_selected, params, container_exe);
+ MESSAGE("[LaunchContainer] remote : \"" << command << "\"");
+ }
//redirect stdout and stderr in a file
#ifdef WIN32
command += " > " + logFilename + " 2>&1";
MakeTheCommandToBeLaunchedASync(command);
+ MESSAGE("[LaunchContainer] SYSTEM COMMAND that will be launched : \"" << command << "\"");
// launch container with a system call
status=SystemThreadSafe(command.c_str());
}//end of critical of section
std::string wdir = params.workingdir.in();
if (!_isAppliSalomeDefined)
{
+ MESSAGE("[BuildCommandToLaunchRemoteContainer] NO APPLI MODE : " << " Protocol :" << resInfo.Protocol << " hostname :" << resInfo.HostName << " username : " << resInfo.UserName << " appli : " << resInfo.AppliPath << " wdir : \"" << wdir << "\"");
command = getCommandToRunRemoteProcessNoAppli(resInfo.Protocol, resInfo.HostName,
resInfo.UserName, resInfo.AppliPath,
wdir);
}
else
{
+ MESSAGE("[BuildCommandToLaunchRemoteContainer] WITH APPLI MODE : " << " Protocol :" << resInfo.Protocol << " hostname :" << resInfo.HostName << " username : " << resInfo.UserName << " appli : " << resInfo.AppliPath << " wdir : \"" << wdir << "\"");
// "ssh -l user machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir
// SALOME_Container containerName -ORBInitRef NameService=IOR:01000..."
// or
class ScriptRemoteParameters:
def __init__(self, args):
- self.debug = False
- if args[0] == "-d":
- self.debug = True
- args = args[1:]
-
+ import KernelBasis
+ self.debug = KernelBasis.VerbosityActivated()
self.protocol = args[0]
self.user = self._read_arg(args[1], "NULL")
self.host = self._read_arg(args[2], "NULL")
# ----------------------------------------------
def command(args):
+ import KernelBasis
options = ScriptRemoteParameters(args)
- if options.debug: print(options)
+ if options.debug:
+ KernelBasis.WriteInStdout( str(options) )
# build command depending on protocol
cmd = []
if options.workdir:
cmd.append("-d " + options.workdir)
- cmd.append("--")
+ cmd.append("--")
# elif ignore other appli_mode value
class ScriptRemoteParameters:
def __init__(self, args):
- self.debug = False
- if args[0] == "-d":
- self.debug = True
- args = args[1:]
-
+ import KernelBasis
+ self.debug = KernelBasis.VerbosityActivated()
self.protocol = args[0]
self.user = self._read_arg(args[1], "NULL")
self.host = self._read_arg(args[2], "NULL")
# ----------------------------------------------
def command(args):
+ import KernelBasis
options = ScriptRemoteParameters(args)
- if options.debug: print(options)
+ if options.debug:
+ KernelBasis.WriteInStdout( str(options) )
# build command depending on protocol
cmd = []
if options.workdir:
cmd.append("-d " + options.workdir)
- cmd.append("--")
+ cmd.append("--")
# elif ignore other appli_mode value
class ScriptLocalParameters:
def __init__(self, args):
- self.debug = False
- if args[0] == "-d":
- self.debug = True
- args = args[1:]
-
+ import KernelBasis
+ self.debug = KernelBasis.VerbosityActivated()
self.nb_proc = self._read_arg(args[0], "NULL")
self.workdir = self._read_arg(args[1], "NULL")
self.isTmpDir = True if args[2] == "1" else False