type(logm).NaiveFetch = LogManagerNaiveFetch
type(logm).Fetch = LogManagerFetch
type(logm).DumpInFile = LogManagerDumpInFile
- type(logm).LoadFromFile = LogManagerLoadFromFile
type(logm).LaunchMonitoringDumpFile = LogManagerLaunchMonitoringDumpFile
type(logm).GetLatestMonitoringDumpFile = LogManagerGetLatestMonitoringDumpFile
#
with open(fileName,"wb") as f:
f.write( self.getAllStruct( clearMemory ) )
-def LogManagerLoadFromFile(self,fileName):
- from SALOME_ContainerHelper import unserializeLogManager
- with open(fileName,"rb") as f:
- data = f.read()
- return unserializeLogManager( data )
class LogManagerLaunchMonitoringFileCtxMgr:
def __init__(self, intervalInMs, outFileName):
pid = KernelBasis.LaunchMonitoring( tempPyFile )
return SALOME_PyNode.MonitoringInfo(pyFileName,None,pid)
+def LogManagerLoadFromFile(fileName):
+ from SALOME_ContainerHelper import unserializeLogManager
+ with open(fileName,"rb") as f:
+ data = f.read()
+ return unserializeLogManager( data )
+
+def LogManagerLoadFromIORFile( iorFile ):
+ global orb
+ def LoadAndWrite(logm,tempFileName):
+ import SALOME_PyNode
+ print( tempFileName )
+ logm.putStructInFileAtomic( False, tempFileName )
+ tempFileAuto = SALOME_PyNode.FileDeleter( tempFileName )
+ ret = LogManagerLoadFromFile( tempFileAuto.filename )
+ return ret
+ with open(iorFile,"r") as f:
+ ior = f.read()
+ import Engines
+ import tempfile
+ salome_init_without_session()
+ logm = orb.string_to_object( ior )
+ with tempfile.NamedTemporaryFile(dir=os.path.expanduser("~")) as f:
+ tempFileName = f.name
+ return LoadAndWrite( logm, tempFileName )
+
def LogManagerGetLatestMonitoringDumpFile(self):
import shutil
import logging
with tempfile.TemporaryDirectory() as tmpdirnameMonitoring:
monitoringFile = os.path.join( str( tmpdirnameMonitoring ), "zeHtop.pckl" )
monitoringFileTwo = os.path.join( str( tmpdirnameMonitoring ), "zeHtopTwo.pckl" )
+ iorLogm = os.path.join( str( tmpdirnameMonitoring ), "logm.ior" )
logging.debug("Monitoring file : {}".format(monitoringFile))
with tempfile.TemporaryDirectory() as tmpdirname:
with salome.LogManagerLaunchMonitoringFileCtxMgr(250,monitoringFile) as monitoringParams:
#
fname = os.path.join(str( tmpdirname ),"perf.log")
salome.logm.DumpInFile( fname )
- logManagerInst0 = salome.logm.LoadFromFile( fname )
+ logManagerInst0 = salome.LogManagerLoadFromFile( fname )
logging.debug( logManagerInst0[0][1][0].get()._input_hdd_mem._data[1]._data[0]._data[0]._hdd_mem ) # important
logManagerInst = salome.logm.Fetch(True)
logManagerInst2 = salome.logm.Fetch(True)
salome.logm.putStructInFileAtomic(False,monitoringFileTwo)
- logging.debug( salome.logm.LoadFromFile(monitoringFileTwo)[0][1][0].get() )
+ logging.debug( salome.LogManagerLoadFromFile(monitoringFileTwo)[0][1][0].get() )
logging.debug( logManagerInst[0][1][0].get()._input_hdd_mem._data[1]._data[0]._data[0]._hdd_mem ) # important
self.assertTrue( logManagerInst2[0][1][0].get() is None )
self.assertTrue( logManagerInst[0][1][1].get()._output_hdd_mem._data[0]._file_name == fileNamesProxyOut2[0] )
pass
#self.assertEqual(monitoringFileSafe, monitoringFile)
self.assertEqual( len( glob.glob("{}*".format(monitoringFile) ) ) , 1 )
- logging.debug( salome.logm.LoadFromFile(monitoringFile)[0][1][0].get() )
+ logging.debug( salome.LogManagerLoadFromFile(monitoringFile)[0][1][0].get() )
del monitoringParams
import gc ; gc.collect()
self.assertFalse( os.path.exists(pyFileContainingCodeOfMonitoring) )