*/
PyNode createPyNode(in string nodeName, in string code) raises(SALOME::SALOME_Exception);
+ //! Retrieves the last created PyNode instance with createPyNode.
+ PyNode getDefaultPyNode();
+
//! Create a PyScriptNode in the container
/*!
\param nodeName the name of the PyScriptNode
\param code python code as text to load in the node
*/
PyScriptNode createPyScriptNode(in string nodeName, in string code) raises(SALOME::SALOME_Exception);
+
+ //! Retrieves the last created PyScriptNode instance with createPyScriptNode.
+ PyScriptNode getDefaultPyScriptNode();
};
/*! \brief Interface to pass data files from the client side to the SALOME Container.
interface PyScriptNode : 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);
/*! \brief execute a python script defined in the node
{
CORBA::Object_var obj = _orb->string_to_object(astr.c_str());
node = Engines::PyNode::_narrow(obj);
+ _dftPyNode = node;
return node._retn();
}
else
}
+//=============================================================================
+/*! \brief Retrieves the last created PyNode instance with createPyNode.
+ *
+ */
+//=============================================================================
+Engines::PyNode_ptr Engines_Container_i::getDefaultPyNode()
+{
+ if(!CORBA::is_nil(_dftPyNode))
+ return Engines::PyNode::_duplicate(_dftPyNode);
+ else
+ return Engines::PyNode::_nil();
+}
+
//=============================================================================
/*! \brief create a PyScriptNode object to execute remote python code
* \param nodeName the name of the node
{
CORBA::Object_var obj = _orb->string_to_object(astr.c_str());
node = Engines::PyScriptNode::_narrow(obj);
+ _dftPyScriptNode = node;
return node._retn();
}
else
}
}
+//=============================================================================
+/*! \brief Retrieves the last created PyScriptNode instance with createPyScriptNode.
+ *
+ */
+//=============================================================================
+Engines::PyScriptNode_ptr Engines_Container_i::getDefaultPyScriptNode()
+{
+ if(!CORBA::is_nil(_dftPyScriptNode))
+ return Engines::PyScriptNode::_duplicate(_dftPyScriptNode);
+ else
+ return Engines::PyScriptNode::_nil();
+}
+
//=============================================================================
/* int checkifexecutable(const char *filename)
*
virtual Engines::Salome_file_ptr createSalome_file(const char* origFileName);
void copyFile(Engines::Container_ptr container, const char* remoteFile, const char* localFile);
Engines::PyNode_ptr createPyNode(const char* nodeName, const char* code);
+ Engines::PyNode_ptr getDefaultPyNode();
Engines::PyScriptNode_ptr createPyScriptNode(const char* nodeName, const char* code);
+ Engines::PyScriptNode_ptr getDefaultPyScriptNode();
// --- local C++ methods
Engines::EngineComponent_ptr
std::map<std::string,Engines::EngineComponent_var> _listInstances_map;
std::map<std::string,Engines::fileRef_var> _fileRef_map;
std::map<std::string,Engines::Salome_file_var> _Salome_file_map;
+ Engines::PyScriptNode_var _dftPyScriptNode;
+ Engines::PyNode_var _dftPyNode;
std::list<std::string> _tmp_files;
Engines::fileTransfer_var _fileTransfer;
self.context={}
self.context["my_container"] = self.my_container
+ 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,outargsname,argsin):
"""Execute the script stored in attribute ccode with pickled args (argsin)"""
try: