#include "SalomeContainerHelper.hxx"
#include "ServiceNode.hxx"
-#include "YacsTrace.hxx"
+
+#include "utilities.h"
#include <sstream>
#include <iostream>
return ;
try
{
- DEBTRACE("shutdown SALOME container: " );
CORBA::String_var containerName=_trueCont->name();
- DEBTRACE(containerName);
+ INFO_MESSAGE("shutdown SALOME container: " << containerName);
_trueCont->Shutdown();
- std::cerr << "shutdown SALOME container: " << containerName << std::endl;
}
catch(...)
{
- DEBTRACE("Unknown exception ignored." );
+ ERROR_MESSAGE("Unknown exception ignored." );
}
_trueCont=Engines::Container::_nil();
}
{
try
{
- DEBTRACE("shutdown SALOME container: " );
CORBA::String_var containerName=it->second->name();
- DEBTRACE(containerName);
+ INFO_MESSAGE("shutdown SALOME container: " << containerName);
it->second->Shutdown();
- std::cerr << "shutdown SALOME container: " << containerName << std::endl;
}
catch(CORBA::Exception&)
{
- DEBTRACE("Unexpected CORBA failure detected." );
+ ERROR_MESSAGE("Unexpected CORBA failure detected." );
}
catch(...)
{
- DEBTRACE("Unknown exception ignored." );
+ ERROR_MESSAGE("Unknown exception ignored." );
}
}
_containersForTasks.clear();
{
try
{
- DEBTRACE("shutdown SALOME container: " );
CORBA::String_var containerName=it->second->name();
- DEBTRACE(containerName);
+ INFO_MESSAGE("shutdown SALOME container: " << containerName);
it->second->Shutdown();
std::cerr << "shutdown SALOME container: " << containerName << std::endl;
}
catch(CORBA::Exception&)
{
- DEBTRACE("Unexpected CORBA failure detected." );
+ ERROR_MESSAGE("Unexpected CORBA failure detected." );
}
catch(...)
{
- DEBTRACE("Unknown exception ignored." );
+ ERROR_MESSAGE("Unknown exception ignored." );
}
}
_containersForComponents.clear();
import loader
import SALOMERuntime
import salome
+import logging
+
+"""
+struct arguments
+{
+ char *args[1];
+ int display = 0;
+ int verbose = 0;
+ int stop = 0;
+ std::string dumpErrorFile;
+ std::string finalDump;
+ int dump = 0;
+ std::string xmlSchema;
+ std::string loadState;
+ int shutdown = 10; # done
+ int reset = 0;
+ int killPort = 0;
+ bool squeezeMemory = true;
+ std::list<std::string> init_ports;
+};
+
+ {"display", 'd', "level", 0, "Display dot files: 0=never to 3=very often (default 0)"},
+ {"verbose", 'v', 0, 0, "Produce verbose output" },
+ {"stop-on-error", 's', 0, 0, "Stop on first error" },
+ {"dump-on-error", 'e', "file", OPTION_ARG_OPTIONAL, "Stop on first error and dump state"},
+ {"dump-final", 'f', "file", OPTION_ARG_OPTIONAL, "dump final state"},
+ {"dump", 'g', "nbsec", OPTION_ARG_OPTIONAL, "dump state"},
+ {"load-state", 'l', "file", 0, "Load State from a previous partial execution"},
+ {"save-xml-schema", 'x', "file", OPTION_ARG_OPTIONAL, "dump xml schema"},
+ {"shutdown", 't', "level", 0, "Shutdown the schema: 0=no shutdown to 3=full shutdown (default 1)"},
+ {"reset", 'r', "level", 0, "Reset the schema before execution: 0=nothing, 1=reset error nodes to ready state (default 0)"},
+ {"kill-port", 'k', "port", 0, "Kill Salome application running on the specified port if the driver process is killed (with SIGINT or SIGTERM)"},
+ {"init_port", 'i', "value", OPTION_ARG_OPTIONAL, "Initialisation value of a port, specified as bloc.node.port=value."},
+ {"donotsqueeze", 'z', "value", 0, "Desactivate squeeze memory optimization."},
+
+"""
my_runtime_yacs = None
import SALOMERuntime
global my_runtime_yacs
if my_runtime_yacs:
- return
+ return
salome.salome_init()
- SALOMERuntime.RuntimeSALOME.setRuntime()
+ flags = SALOMERuntime.RuntimeSALOME.UsePython + SALOMERuntime.RuntimeSALOME.UseCorba + SALOMERuntime.RuntimeSALOME.UseXml + SALOMERuntime.RuntimeSALOME.UseCpp + SALOMERuntime.RuntimeSALOME.UseSalome
+ SALOMERuntime.RuntimeSALOME.setRuntime( flags )
my_runtime_yacs = SALOMERuntime.getSALOMERuntime()
+ anIOR = salome.orb.object_to_string ( salome.modulcat )
+ aCatalog = my_runtime_yacs.loadCatalog( "session", anIOR )
+ my_runtime_yacs.addCatalog( aCatalog )
def SALOMEInitializationNeeded(func):
def decaratedFunc(*args,**kwargs):
- initializeSALOME()
- return func(*args,**kwargs)
+ initializeSALOME()
+ return func(*args,**kwargs)
return decaratedFunc
@SALOMEInitializationNeeded
"""
l=loader.YACSLoader()
p=l.load( xmlFileName )
- print(type(p))
return p
+def patchGraph( proc, squeezeMemory):
+ """
+ Args:
+ -----
+
+ proc ( SALOMERuntime.SalomeProc ) : YACS Proc instance to be evaluated
+ squeezeMemory ( bool ) : squeezememory to be activated
+
+ Returns
+ -------
+
+
+
+ """
+ if squeezeMemory:
+ logging.info("SqueezeMemory requested -> update proc")
+ allNodes = proc.getAllRecursiveNodes()
+ for node in allNodes:
+ if isinstance(proc,SALOMERuntime.PythonNode):
+ node.setSqueezeStatus( True )
+
+
@SALOMEInitializationNeeded
def executeGraph( proc ):
"""
ex.RunW(proc,0)
pass
-def destroyElementsGeneratedByExecutionOfGraph():
- salome.cm
+@SALOMEInitializationNeeded
+def destroyElementsGeneratedByExecutionOfGraph( proc, shutdown ):
+ """
+ Args:
+ -----
+
+ shutdown (int) : shutdown level
+
+ """
+ if shutdown < 999:
+ proc.shutdown(shutdown)
+ salome.dsm.shutdownScopes()
my_runtime_yacs.fini( False )
if __name__ == "__main__":
+ from salome_utils import positionVerbosityOfLoggerRegardingState,setVerboseLevel,setVerbose
import argparse
parser = argparse.ArgumentParser()
- parser.add_argument('xmlfilename',help="XML file containing YACS schema to be executed")
+ parser.add_argument('xmlfilename',help = "XML file containing YACS schema to be executed")
+ parser.add_argument("-v", "--verbose", dest = "verbose",help="Produce verbose output", action='store_true')
+ parser.add_argument("-kt", "--kerneltrace", dest = "kerneltrace",help="Produce verbose of SALOME/KERNEL", action='store_true')
+ parser.add_argument("--shutdown", dest = 'shutdown', type=int , default=1, help="Shutdown the schema: 0=no shutdown to 3=full shutdown")
+ parser.add_argument("-z","--donotsqueeze", dest = "donotsqueeze", help = "Desactivate squeeze memory optimization.", action='store_true')
args = parser.parse_args()
+ #
+ if args.verbose:
+ setVerbose( args.kerneltrace )
+ setVerboseLevel(logging.INFO)
+ positionVerbosityOfLoggerRegardingState()
+ #
proc = loadGraph( args.xmlfilename )
+ patchGraph( proc, not args.donotsqueeze)
executeGraph( proc )
- destroyElementsGeneratedByExecutionOfGraph()
-
+ destroyElementsGeneratedByExecutionOfGraph( proc, args.shutdown )