void setVerbosity(in boolean activated, in string level);
- //void addInfoOnLevel1(in long pos, in string key, in SALOME::vectorOfByte value);
-
- //void addInfoOnLevel2(in long pos0, in long pos1, in string key, in SALOME::vectorOfByte value);
-
- SALOME::vectorOfByte getAllInfo();
-
//! Shutdown the Container process.
void Shutdown();
interface ContainerScriptExecPerfLog
{
void assign(in SALOME::vectorOfByte value);
+ SALOME::vectorOfByte getObj();
};
typedef sequence<ContainerScriptExecPerfLog> ListOfContainerScriptExecPerfLog;
{
ContainerPerfLog declareContainer(in string contInNS, in string logfile);
ListOfContainerPerfLog listOfContainerLogs();
- SALOME::vectorOfByte getAllInfo();
};
};
AutoPyRef(PyObject *pyobj=nullptr):_pyobj(pyobj) { }
~AutoPyRef() { release(); }
AutoPyRef(const AutoPyRef& other):_pyobj(other._pyobj) { if(_pyobj) Py_XINCREF(_pyobj); }
+ AutoPyRef(AutoPyRef&& other) = default;
AutoPyRef& operator=(const AutoPyRef& other) { if(_pyobj==other._pyobj) return *this; release(); _pyobj=other._pyobj; Py_XINCREF(_pyobj); return *this; }
operator PyObject *() { return _pyobj; }
void set(PyObject *pyobj) { if(pyobj==_pyobj) return ; release(); _pyobj=pyobj; }
}
}
-SALOME::vectorOfByte *Abstract_Engines_Container_i::getAllInfo()
-{
- AutoGIL gstate;
- PyObject *result = PyObject_CallMethod(_pyCont, (char*)"getAllInfo",nullptr);
- char *buffer = nullptr;
- Py_ssize_t length = 0;
- PyBytes_AsStringAndSize(result,&buffer,&length);
- SALOME::vectorOfByte *ret = new SALOME::vectorOfByte;
- ret->length(length);
- for(auto i = 0 ; i < length ; ++i)
- (*ret)[i] = buffer[i];
- Py_XDECREF(result);
- return ret;
-}
-
//=============================================================================
//! Get container host name
/*!
from Utils_Identity import getShortHostName
from salome_utils import verbose
from KernelBasis import VerbosityActivated
-from SALOME_ContainerHelper import ScriptInfo
#=============================================================================
self._poa = self._orb.resolve_initial_references("RootPOA")
self._containerName = containerName
self._logFileName = None
- self._dbg_info = []
self._timeIntervalInMs = dftTimeIntervalInMs
self._logm = None
self._log = None
def create_pyscriptnode(self,nodeName,code):
try:
- self._dbg_info.append( ScriptInfo(nodeName) )
logscript = self._log.addScript(nodeName,code)
node=SALOME_PyNode.PyScriptNode_i(nodeName,code,self._poa,self, logscript)
- node.setIDInContainer(len(self._dbg_info)-1)
- self.addInfoOnLevel1(node.getIDInContainer(),"code",code)
id_o = self._poa.activate_object(node)
comp_o = self._poa.id_to_reference(id_o)
comp_iors = self._orb.object_to_string(comp_o)
if VerbosityActivated():
import salome_utils
salome_utils.positionVerbosityOfLoggerRegardingState()
-
- def addInfoOnLevel1(self, pos, key, value):
- setattr(self._dbg_info[pos],key,value)
-
- def addInfoOnLevel2(self, pos0, pos1, key, value):
- setattr(self._dbg_info[pos0].execs[pos1],key,value)
-
- def addTimeInfoOnLevel2(self, pos0, pos1, key):
- from datetime import datetime
- self.addInfoOnLevel2(pos0, pos1, key,datetime.now())
-
- def getAllInfo(self):
- import pickle
- return pickle.dumps( self._dbg_info )
def monitoringtimeresms(self):
return self._timeIntervalInMs
from collections import defaultdict
+import pickle
+
class ScriptExecInfo:
@classmethod
def GetRepresentationOfTimeDelta(cls,endTime, startTime):
return "{} {}".format(m,UNITS[3])
def __init__(self):
+ self._measure_time_resolution_ms = None
self._cpu_mem_during_exec = None
self._start_exec_time = None
self._end_exec_time = None
self._input_hdd_mem = None
self._output_mem = 0
self._output_hdd_mem = None
+ self._start_pos_log = None
+ self._stop_pos_log = None
+
+ @property
+ def measureTimeResolution(self):
+ return self._measure_time_resolution_ms
+
+ @measureTimeResolution.setter
+ def measureTimeResolution(self, value):
+ self._measure_time_resolution_ms = value
+
+ @property
+ def tracePosStart(self):
+ return self._start_pos_log
+
+ @tracePosStart.setter
+ def tracePosStart(self,value):
+ self._start_pos_log = value
+
+ @property
+ def tracePosStop(self):
+ return self._stop_pos_log
+
+ @tracePosStop.setter
+ def tracePosStop(self,value):
+ self._stop_pos_log = value
@property
def CPUMemDuringExec(self):
return """start exec time = {self.startExecTime}
end exec time = {self.endExecTime}
exec_time = {self.execTimeStr}
+Measure time resolution = {self.measureTimeResolution} ms
CPU and mem monitoring = {self.CPUMemDuringExecStr}
input unpickling and ev load from disk time = {self.inputTimeStr}
output serialization and ev write to disk time = {self.outputTimeStr}
input memory size before exec (MemoryPeak 2x) = {self.inputMemStr}
input memory size from HDD = {self.inputHDDMemStr}
output memory size after exec (MemoryPeak 2x) = {self.outputMemStr}
-output memory size from HDD = {self.outputHDDMemStr}""".format(**locals())
+output memory size from HDD = {self.outputHDDMemStr}
+Start position in log = {self.tracePosStart}
+End position in log = {self.tracePosStop}""".format(**locals())
+
+class ScriptExecInfoDeco:
+ def __init__(self, eff, father):
+ self._eff = eff
+ self._father = father
+ @property
+ def father(self):
+ return self._father
+ def get(self):
+ return self._eff
+ def __getitem__(self,i):
+ return self._eff[i]
+ def __str__(self):
+ return self._eff.__str__()
+ def __repr__(self):
+ return self._eff.__repr__()
+ def log(self):
+ with open(self.father.father.logfile,"rb") as f:
+ cont = f.read()
+ return cont[self._eff.tracePosStart:self._eff.tracePosStop].decode()
class ScriptInfo:
- def __init__(self, nodeName):
- self._node_name = nodeName
- self._code = ""
- self._exec = defaultdict(ScriptExecInfo)
+ def __init__(self, scriptPtr):
+ self._node_name = scriptPtr.getName()
+ self._code = scriptPtr.getCode()
+ self._exec = [pickle.loads(elt.getObj()) for elt in scriptPtr.listOfExecs()]
@property
def execs(self):
def code(self,value):
self._code = value
+ def __len__(self):
+ return len( self._exec )
+
+ def __getitem__(self,i):
+ return self._exec[i]
+
def __str__(self):
- return """code = {self.code}\nexecs = {self.execs}""".format(**locals())
+ return """name = {self.nodeName}\ncode = {self.code}\nexecs = {self.execs}""".format(**locals())
def __repr__(self):
return """ScriptInfo \"{self.nodeName}\"""".format(**locals())
+class ScriptInfoDeco:
+ def __init__(self, eff, father):
+ self._eff = eff
+ self._father = father
+ @property
+ def father(self):
+ return self._father
+ def get(self):
+ return self._eff
+ def __getitem__(self,i):
+ return ScriptExecInfoDeco( self._eff[i], self )
+ def __str__(self):
+ return self._eff.__str__()
+ def __repr__(self):
+ return self._eff.__repr__()
+
+class ContainerLogInfo:
+ def __init__(self,contLogPtr):
+ self._log_file = contLogPtr.getLogFile()
+ self._ns_entry = contLogPtr.getContainerEntryInNS()
+ self._scripts = [ScriptInfo(elt) for elt in contLogPtr.listOfScripts()]
+
+ def log(self):
+ with open(self.logfile,"rb") as f:
+ cont = f.read()
+ return cont.decode()
+
+ @property
+ def ns_entry(self):
+ return self._ns_entry
+
+ @property
+ def logfile(self):
+ return self._log_file
+
+ def __len__(self):
+ return len( self._scripts )
+
+ def __getitem__(self,i):
+ return ScriptInfoDeco( self._scripts[i], self)
+
+ def __str__(self):
+ return """NS entry = {self.ns_entry} LogFile = {self.logfile}""".format(**locals())
+
from abc import ABC, abstractmethod
class InOutputObjVisitorAbstract(ABC):
void monitoringtimeresms(CORBA::Long intervalInMs) override;
void verbosity(bool& activated, CORBA::String_out level) override;
void setVerbosity(bool activated, const char *level) override;
- SALOME::vectorOfByte *getAllInfo() override;
virtual void Shutdown();
char *getHostName();
import logging
import os
import sys
+from SALOME_ContainerHelper import ScriptExecInfo
MY_CONTAINER_ENTRY_IN_GLBS = "my_container"
iStart = iEnd; iEnd = min(iStart + EFF_CHUNK_SIZE,size)
return data_for_split_case
+class LogOfCurrentExecutionSession:
+ def __init__(self, handleToCentralizedInst):
+ self._remote_handle = handleToCentralizedInst
+ self._current_instance = ScriptExecInfo()
+
+ def addInfoOnLevel2(self, key, value):
+ setattr(self._current_instance,key,value)
+
+ def finalizeAndPushToMaster(self):
+ self._remote_handle.assign( pickle.dumps( self._current_instance ) )
+
class PyScriptNode_i (Engines__POA.PyScriptNode,Generic):
"""The implementation of the PyScriptNode CORBA IDL that executes a script"""
def __init__(self, nodeName,code,poa,my_container,logscript):
self.ccode=compile(code,nodeName,'exec')
self.context={}
self.context[MY_CONTAINER_ENTRY_IN_GLBS] = self.my_container
- self._pos = None
- self._current_exec = 0
self._log_script = logscript
self._current_execution_session = None
sys.stdout.flush() ; sys.stderr.flush() # flush to correctly capture log per execution session
-
- #start of non remote callable methods
-
- def setIDInContainer(self, pos):
- """
- Method that store the rank of creation of self inside Container instance
- """
- self._pos = pos
-
- def getIDInContainer(self):
- return self._pos
-
- #end of non remote callable methods
def __del__(self):
# force removal of self.context. Don t know why it s not done by default
def executeFirst(self,argsin):
""" Same than first part of self.execute to reduce memory peak."""
try:
- #self.my_container_py.addInfoOnLevel2(self.getIDInContainer(),self._current_exec,"tracePosStart",)
- self._current_execution_session = self._log_script.addExecutionSession()
+ self.beginOfCurrentExecutionSession()
data = None
- self.my_container_py.addTimeInfoOnLevel2(self.getIDInContainer(),self._current_exec,"startInputTime")
+ self.addTimeInfoOnLevel2("startInputTime")
if True: # to force call of SeqByteReceiver's destructor
argsInPy = SeqByteReceiver( argsin )
data = argsInPy.data()
- self.my_container_py.addInfoOnLevel2(self.getIDInContainer(),self._current_exec,"inputMem",len(data))
+ self.addInfoOnLevel2("inputMem",len(data))
_,kws=pickle.loads(data)
vis = InOutputObjVisitor()
for elt in kws:
# fetch real data if necessary
kws[elt] = UnProxyObjectSimple( kws[elt],vis)
- self.my_container_py.addInfoOnLevel2(self.getIDInContainer(),self._current_exec,"inputHDDMem",vis)
+ self.addInfoOnLevel2("inputHDDMem",vis)
self.context.update(kws)
- self.my_container_py.addTimeInfoOnLevel2(self.getIDInContainer(),self._current_exec,"endInputTime")
+ self.addTimeInfoOnLevel2("endInputTime")
except Exception:
exc_typ,exc_val,exc_fr=sys.exc_info()
l=traceback.format_exception(exc_typ,exc_val,exc_fr)
""" Same than second part of self.execute to reduce memory peak."""
import sys
try:
- self.my_container_py.addTimeInfoOnLevel2(self.getIDInContainer(),self._current_exec,"startExecTime")
+ self.addTimeInfoOnLevel2("startExecTime")
##
+ self.addInfoOnLevel2("measureTimeResolution",self.my_container_py.monitoringtimeresms())
monitoringParams = LaunchMonitoring( self.my_container_py.monitoringtimeresms() )
exec(self.ccode, self.context)
cpumeminfo = StopMonitoring( )
##
- self.my_container_py.addInfoOnLevel2(self.getIDInContainer(),self._current_exec,"CPUMemDuringExec",cpumeminfo)
+ self.addInfoOnLevel2("CPUMemDuringExec",cpumeminfo)
del monitoringParams
- self.my_container_py.addTimeInfoOnLevel2(self.getIDInContainer(),self._current_exec,"endExecTime")
- self.my_container_py.addTimeInfoOnLevel2(self.getIDInContainer(),self._current_exec,"startOutputTime")
+ self.addTimeInfoOnLevel2("endExecTime")
+ self.addTimeInfoOnLevel2("startOutputTime")
argsout=[]
for arg in outargsname:
if arg not in self.context:
retObj = self.poa.id_to_reference(id_o)
ret.append( retObj._narrow( SALOME.SenderByte ) )
outputMem += len(argPickle)
- self.my_container_py.addInfoOnLevel2(self.getIDInContainer(),self._current_exec,"outputMem",outputMem)
- self.my_container_py.addInfoOnLevel2(self.getIDInContainer(),self._current_exec,"outputHDDMem",vis)
- self.my_container_py.addTimeInfoOnLevel2(self.getIDInContainer(),self._current_exec,"endOutputTime")
+ self.addInfoOnLevel2("outputMem",outputMem)
+ self.addInfoOnLevel2("outputHDDMem",vis)
+ self.addTimeInfoOnLevel2("endOutputTime")
+ self.endOfCurrentExecutionSession()
return ret
except Exception:
exc_typ,exc_val,exc_fr=sys.exc_info()
l=traceback.format_exception(exc_typ,exc_val,exc_fr)
raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"".join(l),"PyScriptNode: %s" %self.nodeName,0))
pass
+
+ def beginOfCurrentExecutionSession(self):
+ self._current_execution_session = LogOfCurrentExecutionSession( self._log_script.addExecutionSession() )
+
+ def endOfCurrentExecutionSession(self):
+ self._current_execution_session.finalizeAndPushToMaster()
+ self._current_execution_session = None
+
+ def addInfoOnLevel2(self, key, value):
+ self._current_execution_session.addInfoOnLevel2(key, value)
+
+ def addTimeInfoOnLevel2(self, key):
+ from datetime import datetime
+ self._current_execution_session.addInfoOnLevel2(key,datetime.now())
esm = KernelLauncher.GetExternalServer()
# idem for logm
logm = KernelLauncher.myLogManager()
+ type(logm).Fetch = LogManagerFetch
#
import KernelLogger
naming_service.Register(KernelLogger.myLogger(),"/Logger")
envEff = [ Engines.KeyValPairString(key=k,val=v) for k,v in env ]
return self.SetOverrideEnvForContainers( envEff )
+def LogManagerFetch(self):
+ import SALOME_ContainerHelper
+ return [SALOME_ContainerHelper.ContainerLogInfo(elt) for elt in self.listOfContainerLogs()]
+
#to expose all objects to pydoc
__all__=dir()
SET(LAUNCHER_PYTHON_SCRIPTS
launcher_proxy.py
+ SALOME_LogManager.py
)
SET(KernelLauncher_HEADERS KernelLauncher.hxx KernelLauncher.i)
//
SALOME_CPythonHelper *cPyh(SALOME_CPythonHelper::Singleton());
SALOME_Fake_NamingService *ns = new SALOME_Fake_NamingService;
- SALOME_LogManager *esm(new SALOME_LogManager(cPyh,orb,safePOA,ns));
+ SALOME_LogManager *esm(new SALOME_LogManager(orb,safePOA,ns));
esm->_remove_ref();
//
CORBA::Object_var esmPtr = safePOA->servant_to_reference(esm);
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// Author : Anthony GEAY (EDF R&D)
#include "SALOME_LogManager.hxx"
#include "SALOME_Fake_NamingService.hxx"
#include "SALOME_ContainerManager.hxx"
-#include "SALOME_CPythonHelper.hxx"
#ifndef WIN32
#include <unistd.h>
const char SALOME_LogManager::NAME_IN_NS[]="/LogManager";
+static std::vector<char> FromPyToCpp(PyObject *obj)
+{
+ std::vector<char> ret;
+ char *buffer = nullptr;
+ Py_ssize_t length = 0;
+ PyBytes_AsStringAndSize(obj,&buffer,&length);
+ ret.resize(length);
+ for(auto i = 0 ; i < length ; ++i)
+ ret[i] = buffer[i];
+ return ret;
+}
+
PortableServer::POA_var SALOME_ContainerScriptExecPerfLog::getPOA()
{
return father()->getPOA();
void SALOME_ContainerScriptExecPerfLog::assign(const SALOME::vectorOfByte& value)
{
+ auto sz = value.length();
+ _data.resize( sz );
+ for(auto i = 0 ; i < sz ; ++i)
+ _data[i] = value[i];
+ //
+ AutoPyRef s( this->end( ) );
+ //
+ _data = FromPyToCpp(s);
+}
+
+SALOME::vectorOfByte *SALOME_ContainerScriptExecPerfLog::getObj()
+{
+ SALOME::vectorOfByte_var ret = new SALOME::vectorOfByte;
+ auto length = this->_data.size();
+ ret->length(length);
+ for(auto i = 0 ; i < length ; ++i)
+ ret[i] = _data[i];
+ return ret._retn();
+}
+void SALOME_ContainerScriptExecPerfLog::start()
+{
+ AutoGIL gstate;
+ PyObject *result = PyObject_CallMethod(pyObj(),(char*)"start","",nullptr);
+ if (PyErr_Occurred())
+ {
+ std::string error("can not start");
+ PyErr_Print();
+ THROW_SALOME_CORBA_EXCEPTION(error.c_str(),SALOME::INTERNAL_ERROR);
+ }
+}
+
+AutoPyRef SALOME_ContainerScriptExecPerfLog::end()
+{
+ AutoGIL gstate;
+ //https://docs.python.org/3/c-api/arg.html#c.Py_BuildValue
+ AutoPyRef result(PyObject_CallMethod(pyObj(),(char*)"end","y#",_data.data(),_data.size(),nullptr) ) ;
+ if (PyErr_Occurred())
+ {
+ std::string error("can not end");
+ PyErr_Print();
+ THROW_SALOME_CORBA_EXCEPTION(error.c_str(),SALOME::INTERNAL_ERROR);
+ }
+ return result;
}
/////
CORBA::Object_var executionPtr(getPOA()->id_to_reference(id));
Engines::ContainerScriptExecPerfLog_var executionPtr2 = Engines::ContainerScriptExecPerfLog::_narrow(executionPtr);
_sessions.push_back( executionPtr2 );
- return executionPtr2;
+ {
+ AutoGIL gstate;
+ PyObject *result = PyObject_CallMethod(pyObj(),(char*)"addExecution","",nullptr);
+ if (PyErr_Occurred())
+ {
+ std::string error("can not addExecution");
+ PyErr_Print();
+ THROW_SALOME_CORBA_EXCEPTION(error.c_str(),SALOME::INTERNAL_ERROR);
+ }
+ execution->setPyObj( result );
+ }
+ execution->start();
+ return executionPtr2._retn();
}
Engines::ListOfContainerScriptExecPerfLog *SALOME_ContainerScriptPerfLog::listOfExecs()
{
-
+ Engines::ListOfContainerScriptExecPerfLog_var ret = new Engines::ListOfContainerScriptExecPerfLog;
+ auto sz = this->_sessions.size();
+ ret->length(sz);
+ for(auto i = 0 ; i < sz ; ++i)
+ ret[i] = this->_sessions[i];
+ return ret._retn();
}
/////
CORBA::Object_var scriptPtr(getPOA()->id_to_reference(id));
Engines::ContainerScriptPerfLog_var scriptPtr2 = Engines::ContainerScriptPerfLog::_narrow(scriptPtr);
_scripts.push_back( scriptPtr2 );
- return scriptPtr2;
+ {
+ AutoGIL gstate;
+ PyObject *result = PyObject_CallMethod(pyObj(),(char*)"addScript","",nullptr);
+ if (PyErr_Occurred())
+ {
+ std::string error("can not addScript");
+ PyErr_Print();
+ THROW_SALOME_CORBA_EXCEPTION(error.c_str(),SALOME::INTERNAL_ERROR);
+ }
+ script->setPyObj( result );
+ }
+ return scriptPtr2._retn();
}
Engines::ListOfContainerScriptPerfLog *SALOME_ContainerPerfLog::listOfScripts()
/////
-SALOME_LogManager::SALOME_LogManager(const SALOME_CPythonHelper *pyHelper, CORBA::ORB_ptr orb, PortableServer::POA_var poa,SALOME_NamingService_Abstract *ns):_pyHelper(pyHelper),_poa(poa)
+SALOME_LogManager::SALOME_LogManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa,SALOME_NamingService_Abstract *ns):_poa(poa)
{
_NS.reset(ns);
PortableServer::ObjectId_var id(_poa->activate_object(this));
CORBA::Object_var obj(_poa->id_to_reference(id));
Engines::LogManager_var refPtr(Engines::LogManager::_narrow(obj));
_NS->Register(refPtr,NAME_IN_NS);
-}
-
-SALOME::vectorOfByte *SALOME_LogManager::getAllInfo()
-{
- auto length = 2;
- SALOME::vectorOfByte *ret = new SALOME::vectorOfByte;
- ret->length(length);
- for(auto i = 0 ; i < length ; ++i)
- (*ret)[i] = 1;
- return ret;
+ {
+ AutoGIL gstate;
+ std::ostringstream myCommand;
+ myCommand << "mylogmanager = SALOME_LogManager.SALOME_LogManagerHelper()";
+ PyRun_SimpleString("import SALOME_LogManager");
+ PyRun_SimpleString((char*)myCommand.str().c_str());
+ PyObject *mainmod = PyImport_AddModule("__main__");
+ PyObject *globals = PyModule_GetDict(mainmod);
+ _pyLogManager = PyDict_GetItemString(globals, "mylogmanager");
+ }
}
Engines::ContainerPerfLog_ptr SALOME_LogManager::declareContainer(const char *contInNS, const char *logfile)
cont->_remove_ref();
Engines::ContainerPerfLog_var contPtr2 = Engines::ContainerPerfLog::_narrow(contPtr);
_containers.push_back( contPtr2 );
- return contPtr2;
+ {
+ AutoGIL gstate;
+ PyObject *result = PyObject_CallMethod(_pyLogManager,(char*)"declareContainer","ss",contInNS,logfile,nullptr);
+ if (PyErr_Occurred())
+ {
+ std::string error("can not declareContainer");
+ PyErr_Print();
+ THROW_SALOME_CORBA_EXCEPTION(error.c_str(),SALOME::INTERNAL_ERROR);
+ }
+ cont->setPyObj( result );
+ }
+ return contPtr2._retn();
}
Engines::ListOfContainerPerfLog *SALOME_LogManager::listOfContainerLogs()
std::size_t len( this->_containers.size() );
ret->length( len );
for(std::size_t i = 0 ; i < len ; ++i)
+ {
ret[i] = this->_containers[i];
+ }
return ret._retn();
}
#include "SALOME_Launcher_defs.hxx"
-#include <SALOMEconfig.h>
+#include "Python.h"
+
+#include "PythonCppUtils.hxx"
+#include "Utils_CorbaException.hxx"
+#include "SALOMEconfig.h"
#include CORBA_SERVER_HEADER(SALOME_LogManager)
#include <memory>
class SALOME_NamingService_Abstract;
-class SALOME_CPythonHelper;
class SALOME_LogManager;
class SALOME_ContainerPerfLog;
class SALOME_ContainerScriptPerfLog;
public:
SALOME_ContainerScriptExecPerfLog(SALOME_ContainerScriptPerfLog *father):_father(father) { }
SALOME_ContainerScriptPerfLog *father() const { return _father; }
+ void setPyObj(PyObject *obj) { _pyExecutionLog.set(obj); }
+ PyObject *pyObj() { return _pyExecutionLog.get(); }
PortableServer::POA_var getPOA();
void assign(const SALOME::vectorOfByte& value) override;
+ SALOME::vectorOfByte *getObj() override;
+public:
+ void start();
+ AutoPyRef end();
private:
+ AutoPyRef _pyExecutionLog;
SALOME_ContainerScriptPerfLog *_father = nullptr;
+ std::vector<char> _data;
};
class SALOMELAUNCHER_EXPORT SALOME_ContainerScriptPerfLog : public POA_Engines::ContainerScriptPerfLog
public:
SALOME_ContainerScriptPerfLog(SALOME_ContainerPerfLog *father, const std::string& name, const std::string& code):_father(father),_name(name),_code(code) { }
SALOME_ContainerPerfLog *father() const { return _father; }
+ void setPyObj(PyObject *obj) { _pyScriptLog.set(obj); }
+ PyObject *pyObj() { return _pyScriptLog.get(); }
PortableServer::POA_var getPOA();
Engines::ContainerScriptExecPerfLog_ptr addExecutionSession() override;
Engines::ListOfContainerScriptExecPerfLog *listOfExecs() override;
char *getCode() override;
char *getName() override;
private:
+ AutoPyRef _pyScriptLog;
SALOME_ContainerPerfLog *_father = nullptr;
std::string _name;
std::string _code;
public:
SALOME_ContainerPerfLog(SALOME_LogManager *father, const std::string& nameInNS, const std::string& logFile):_father(father),_name_in_ns(nameInNS),_log_file(logFile) { }
SALOME_LogManager *father() const { return _father; }
+ void setPyObj(PyObject *obj) { _pyContLog.set(obj); }
+ PyObject *pyObj() { return _pyContLog.get(); }
PortableServer::POA_var getPOA();
char *getLogFile() override;
char *getContainerEntryInNS() override;
Engines::ContainerScriptPerfLog_ptr addScript(const char *name, const char *code) override;
Engines::ListOfContainerScriptPerfLog *listOfScripts() override;
private:
+ AutoPyRef _pyContLog;
SALOME_LogManager *_father = nullptr;
std::string _name_in_ns;
std::string _log_file;
class SALOMELAUNCHER_EXPORT SALOME_LogManager : public POA_Engines::LogManager
{
public:
- SALOME_LogManager(const SALOME_CPythonHelper *pyHelper, CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService_Abstract *ns = nullptr);
+ SALOME_LogManager(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService_Abstract *ns = nullptr);
PortableServer::POA_var getPOA() { return _poa; }
+ PyObject *pyHelper() const { return _pyLogManager; }
virtual ~SALOME_LogManager() = default;
- SALOME::vectorOfByte *getAllInfo() override;
Engines::ContainerPerfLog_ptr declareContainer(const char *contInNS, const char *logfile) override;
Engines::ListOfContainerPerfLog *listOfContainerLogs() override;
- public:
- const SALOME_CPythonHelper *getPyHelper() const { return _pyHelper; }
private:
- const SALOME_CPythonHelper *_pyHelper = nullptr;
+ PyObject *_pyLogManager = nullptr;
std::unique_ptr<SALOME_NamingService_Abstract> _NS;
PortableServer::POA_var _poa;
std::vector<Engines::ContainerPerfLog_var> _containers;
--- /dev/null
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2024 CEA, EDF
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+import os
+import sys
+import pickle
+from SALOME_ContainerHelper import ScriptExecInfo
+
+class SALOME_ContainerScriptExecPerfLog:
+ def __init__(self, father):
+ self._father = father
+ self._start_pos = None
+ self._stop_pos = None
+
+ @property
+ def father(self):
+ return self._father
+
+ def end(self,s):
+ obj = pickle.loads(s)
+ self._stop_pos = os.path.getsize( self.father.father.logfilename )
+ setattr(obj,"tracePosStop",self._stop_pos)
+ setattr(obj,"tracePosStart",self._start_pos)
+ return pickle.dumps(obj)
+
+ def start(self):
+ self._start_pos = os.path.getsize( self.father.father.logfilename )
+
+class SALOME_ContainerScriptPerfLog:
+ def __init__(self, father):
+ self._father = father
+
+ @property
+ def father(self):
+ return self._father
+
+ def addExecution(self):
+ return SALOME_ContainerScriptExecPerfLog(self)
+
+class SALOME_ContainerPerfLog:
+ def __init__(self,contInNS,logfile):
+ self._container_in_ns = contInNS
+ self._log_filename = logfile
+
+ @property
+ def logfilename(self):
+ return self._log_filename
+
+ @property
+ def father(self):
+ return self._father
+
+ def addScript(self):
+ return SALOME_ContainerScriptPerfLog(self)
+
+class SALOME_LogManagerHelper:
+ def __init__(self):
+ pass
+
+ def declareContainer(self, contInNS,logfile):
+ inst = SALOME_ContainerPerfLog(contInNS,logfile)
+ return inst