From 860c1d9008d3da9754088097ec64945a50bd0084 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Tue, 16 Sep 2014 10:56:02 +0200 Subject: [PATCH] Correction of bug for HPContainers shared by different scripts. --- idl/SALOME_PyNode.idl | 7 +++++++ src/Container/SALOME_PyNode.py | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/idl/SALOME_PyNode.idl b/idl/SALOME_PyNode.idl index ba3bfaadb..5faf372ac 100644 --- a/idl/SALOME_PyNode.idl +++ b/idl/SALOME_PyNode.idl @@ -61,6 +61,13 @@ module Engines interface PyScriptNode : PyNodeBase { + /*! + This method compiles, but NOT EXECUTE, the code \a codeStr. The result of the compiled code will be used then + on execute step. + \param codeStr - the python code (without statement) to be executed, that can modify the context initialized at initialization. + */ + void assignNewCompiledCode(in string codeStr) raises (SALOME::SALOME_Exception); + /*! \brief execute a python script defined in the node \param outargsname output argument names diff --git a/src/Container/SALOME_PyNode.py b/src/Container/SALOME_PyNode.py index 9cbc8a615..07f1f7bae 100644 --- a/src/Container/SALOME_PyNode.py +++ b/src/Container/SALOME_PyNode.py @@ -106,6 +106,13 @@ class PyScriptNode_i (Engines__POA.PyScriptNode,Generic): except: raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"","PyScriptNode (%s) : code to be executed \"%s\"" %(self.nodeName,code),0)) + def assignNewCompiledCode(self,codeStr): + try: + self.code=codeStr + self.ccode=compile(codeStr,self.nodeName,'exec') + except: + raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"","PyScriptNode.assignNewCompiledCode (%s) : code to be executed \"%s\"" %(self.nodeName,codeStr),0)) + def execute(self,outargsname,argsin): """Execute the script stored in attribute ccode with pickled args (argsin)""" try: -- 2.39.2