From 73fab8d075b491bd72df15412584620b17bf0d0a Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Fri, 19 Apr 2024 15:32:22 +0200 Subject: [PATCH] [EDF29138] : Ease usage of replay mode --- src/Container/SALOME_PyNode.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/Container/SALOME_PyNode.py b/src/Container/SALOME_PyNode.py index 26493bf81..06c958fb3 100644 --- a/src/Container/SALOME_PyNode.py +++ b/src/Container/SALOME_PyNode.py @@ -873,21 +873,38 @@ def ExecLocal( code, context, outargsname, containerRef, instanceOfLogOfCurrentS exec( code, context ) return instanceOfLogOfCurrentSession._current_instance -class LogOfCurrentExecutionSession: +class LogOfCurrentExecutionSessionAbs(Generic,abc.ABC): + def __init__(self): + self._current_instance = ScriptExecInfo() + + def addInfoOnLevel2(self, key, value): + setattr(self._current_instance,key,value) + + @abc.abstractmethod + def addFreestyleAndFlush(self, outargsname): + raise RuntimeError("Must be overloaded") + +class LogOfCurrentExecutionSession(LogOfCurrentExecutionSessionAbs): def __init__(self, handleToCentralizedInst): + super().__init__() self._remote_handle = handleToCentralizedInst - self._current_instance = ScriptExecInfo() def addFreestyleAndFlush(self, value): self._current_instance.freestyle = value self.finalizeAndPushToMaster() - def addInfoOnLevel2(self, key, value): - setattr(self._current_instance,key,value) - def finalizeAndPushToMaster(self): self._remote_handle.assign( pickle.dumps( self._current_instance ) ) +class LogOfCurrentExecutionSessionStub(LogOfCurrentExecutionSessionAbs): + """ + This class is to stub LogOfCurrentExecutionSession in context of replay where the server (handleToCentralizedInst) has vanished + """ + def __init__(self, handleToCentralizedInst = None): + super().__init__() + def addFreestyleAndFlush(self): + pass + class PyScriptNode_Abstract_i(Engines__POA.PyScriptNode,Generic,abc.ABC): """The implementation of the PyScriptNode CORBA IDL that executes a script""" def __init__(self, nodeName, code, poa, my_container, logscript): -- 2.30.2