]> SALOME platform Git repositories - modules/yacs.git/commitdiff
Salome HOME
Makes the remote interpretor or Salome accessible for both PyScriptNode and PyNode.
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 13 Aug 2014 13:09:05 +0000 (15:09 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 13 Aug 2014 13:09:05 +0000 (15:09 +0200)
idl/SALOME_PyNode.idl
src/Container/SALOME_PyNode.py

index 401b3b0e906e828aaf66f91bed50d5ffcbe15c45..ba3bfaadb665a60a2b15c2d328c6eaa9da97f6e6 100644 (file)
@@ -38,27 +38,29 @@ module Engines
   typedef sequence<octet> pickledArgs;
   typedef sequence<string> listofstring;
 
-  interface PyNode : SALOME::GenericObj
+  interface PyNodeBase : SALOME::GenericObj
   {
+    /*!
+    This methode executes the python code in \a codeStr and can append/remove symboles in context to make them available or not for future call of execute on this.
+    \param [in] codeStr - the python code (without statement) to be executed, that can modify the context initialized at initialization.
+     */
+    void executeAnotherPieceOfCode(in string codeStr) raises (SALOME::SALOME_Exception);
+  };
 
+  interface PyNode : PyNodeBase
+  {
     /*! \brief execute a python function defined in the node
 
       \param functionName the python function defined in the node to execute
       \param inargs input argument values (tuple,dict) provided as a python pickle
       \return output argument values (tuple) as a python pickle
     */
-    pickledArgs execute(in string functionName,in pickledArgs inargs) raises (SALOME::SALOME_Exception);
+    pickledArgs execute(in string functionName, in pickledArgs inargs) raises (SALOME::SALOME_Exception);
 
   } ;
 
-  interface PyScriptNode : SALOME::GenericObj
+  interface PyScriptNode : PyNodeBase
   {
-    /*!
-    This methode executes the python code in \a codeStr and can append/remove symboles in context to make them available or not for future call of execute on this.
-    \param [in] codeStr - the python code (without statement) to be executed, that can modify the context initialized at initialization.
-     */
-    void executeAnotherPieceOfCode(in string codeStr)  raises (SALOME::SALOME_Exception);
-
     /*! \brief execute a python script defined in the node
 
       \param outargsname output argument names 
index 2f8418fab82fc6e5542bbeda8755434c9251c68e..9cbc8a615f1f17f8ddceacc0786c790d1a341cd5 100644 (file)
@@ -64,6 +64,14 @@ class PyNode_i (Engines__POA.PyNode,Generic):
     self.context["my_container"] = self.my_container
     exec ccode in self.context
 
+  def executeAnotherPieceOfCode(self,code):
+    """Called for initialization of container lodging self."""
+    try:
+      ccode=compile(code,self.nodeName,'exec')
+      exec ccode in self.context
+    except:
+      raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"","PyScriptNode (%s) : code to be executed \"%s\"" %(self.nodeName,code),0))
+
   def execute(self,funcName,argsin):
     """Execute the function funcName found in local context with pickled args (argsin)"""
     try: