Version: 8.3.0
YACS::ENGINE::DistributedPythonNode Class Reference

#include <DistributedPythonNode.hxx>

Inheritance diagram for YACS::ENGINE::DistributedPythonNode:
Collaboration diagram for YACS::ENGINE::DistributedPythonNode:

Public Member Functions

 DistributedPythonNode (const std::string &name)
 
 DistributedPythonNode (const DistributedPythonNode &other, ComposedNode *father)
 
 ~DistributedPythonNode ()
 
void execute ()
 
void load ()
 
std::string getEffectiveKindOfServer () const
 this method returns the type of container expected More...
 
std::string getKind () const
 this method returns the type of input/output expected More...
 
ServerNodecreateNode (const std::string &name) const
 
virtual std::string typeName ()
 
- Public Member Functions inherited from YACS::ENGINE::ServerNode
 ServerNode (const std::string &name)
 
 ServerNode (const ServerNode &other, ComposedNode *father)
 
void accept (Visitor *visitor)
 
bool isDeployable () const
 By definition of ServerNode class. More...
 
virtual ~ServerNode ()
 
- Public Member Functions inherited from YACS::ENGINE::InlineFuncNode
virtual void setFname (const std::string &fname)
 Set the function name to use in node execution. More...
 
virtual std::string getFname ()
 
virtual ~InlineFuncNode ()
 
virtual void checkBasicConsistency () const throw (Exception)
 
- Public Member Functions inherited from YACS::ENGINE::InlineNode
virtual void setScript (const std::string &script)
 Set the script (as a string) to execute. More...
 
virtual std::string getScript ()
 
virtual InlineNodecloneNode (const std::string &name)
 Return a new InlineNode node by making a copy of this node. More...
 
virtual ~InlineNode ()
 
virtual void setExecutionMode (const std::string &mode)
 
virtual std::string getExecutionMode ()
 
virtual void setContainer (Container *container)
 
virtual ContainergetContainer ()
 
void performDuplicationOfPlacement (const Node &other)
 performs a duplication of placement using clone method of containers and components. clone behaviour is driven by attachOnCloning attribute. More...
 
void performShallowDuplicationOfPlacement (const Node &other)
 performs a also duplication of placement but here containers and components are not copied at all whatever the value of attachedOnCloning. More...
 
int getMaxLevelOfParallelism () const
 
- Public Member Functions inherited from YACS::ENGINE::ElementaryNode
virtual ~ElementaryNode ()
 
void exUpdateState ()
 Update the node state. More...
 
void init (bool start=true)
 
ComponentInstancegetComponent ()
 
const ComponentInstancegetComponent () const
 
YACS::StatesForNode getState () const
 
void getReadyTasks (std::vector< Task * > &tasks)
 
void edRemovePort (Port *port) throw (Exception)
 
std::list< ElementaryNode * > getRecursiveConstituents () const
 
std::list< ProgressWeightgetProgressWeight () const
 Get the progress weight for all elementary nodes. More...
 
NodegetChildByName (const std::string &name) const throw (Exception)
 
ComposedNodegetDynClonerIfExists (const ComposedNode *levelToStop) const
 
int getNumberOfInputPorts () const
 
int getNumberOfOutputPorts () const
 
std::string getInPortName (const InPort *) const throw (Exception)
 
std::string getOutPortName (const OutPort *) const throw (Exception)
 
InputPortgetInputPort (const std::string &name) const throw (Exception)
 
OutputPortgetOutputPort (const std::string &name) const throw (Exception)
 
std::list< InputPort * > getSetOfInputPort () const
 
std::list< OutputPort * > getSetOfOutputPort () const
 
std::list< InputPort * > getLocalInputPorts () const
 
std::list< OutputPort * > getLocalOutputPorts () const
 
std::set< OutPort * > getAllOutPortsLeavingCurrentScope () const
 
std::set< InPort * > getAllInPortsComingFromOutsideOfCurrentScope () const
 
virtual std::vector< std::pair
< OutPort *, InPort * > > 
getSetOfLinksLeavingCurrentScope () const
 
virtual std::vector< std::pair
< InPort *, OutPort * > > 
getSetOfLinksComingInCurrentScope () const
 
std::list< InputDataStreamPort * > getSetOfInputDataStreamPort () const
 
std::list< OutputDataStreamPort * > getSetOfOutputDataStreamPort () const
 
InputDataStreamPortgetInputDataStreamPort (const std::string &name) const throw (Exception)
 
OutputDataStreamPortgetOutputDataStreamPort (const std::string &name) const throw (Exception)
 
virtual InputPortcreateInputPort (const std::string &inputPortName, TypeCode *type)
 
virtual OutputPortcreateOutputPort (const std::string &outputPortName, TypeCode *type)
 
virtual InputDataStreamPortcreateInputDataStreamPort (const std::string &inputPortDSName, TypeCode *type)
 
virtual OutputDataStreamPortcreateOutputDataStreamPort (const std::string &outputPortDSName, TypeCode *type)
 
virtual InputPortedAddInputPort (const std::string &inputPortName, TypeCode *type) throw (Exception)
 
virtual OutputPortedAddOutputPort (const std::string &outputPortName, TypeCode *type) throw (Exception)
 
virtual InputDataStreamPortedAddInputDataStreamPort (const std::string &inputPortDSName, TypeCode *type) throw (Exception)
 
virtual OutputDataStreamPortedAddOutputDataStreamPort (const std::string &outputPortDSName, TypeCode *type) throw (Exception)
 
virtual void edOrderInputPorts (const std::list< InputPort * > &ports)
 
virtual void edOrderOutputPorts (const std::list< OutputPort * > &ports)
 
virtual void edUpdateState ()
 update the status of the node More...
 
virtual void ensureLoading ()
 Put this node into TOLOAD state when possible. More...
 
void begin ()
 
bool isReady ()
 
void finished ()
 
void aborted ()
 
void loaded ()
 Notify this node that it is loaded. More...
 
void connected ()
 Notify this node that it is connected. More...
 
virtual std::string getErrorDetails ()
 Give a description of error when node status is ERROR. More...
 
virtual void initService ()
 
virtual void connectService ()
 
virtual void disconnectService ()
 
virtual void getCoupledTasks (std::set< Task * > &coupledSet)
 Calls getCoupledNodes for Task interface. More...
 
virtual void getCoupledNodes (std::set< Task * > &coupledSet)
 Put all nodes that are coupled to this node in coupledSet. More...
 
virtual void addDatastreamPortToInitMultiService (const std::string &port_name, int number)
 
template<class PORT >
void edRemovePortTypedFromSet (PORT *port, std::list< PORT * > &setOfPorts) throw (Exception)
 
template<class PORT >
bool isPortNameAlreadyExist (const std::string &portName, const std::list< PORT * > &setOfPorts)
 
- Public Member Functions inherited from YACS::ENGINE::Node
virtual ~Node ()
 
virtual void shutdown (int level)
 Stop all pending activities of the node. More...
 
virtual void resetState (int level)
 Reset the node state depending on the parameter level. More...
 
Nodeclone (ComposedNode *father, bool editionOnly=true) const
 This method MUST NEVER BE VIRTUAL More...
 
NodecloneWithoutCompAndContDeepCpy (ComposedNode *father, bool editionOnly=true) const
 This method MUST NEVER BE VIRTUAL More...
 
void setState (YACS::StatesForNode theState)
 Sets the given state for node. More...
 
virtual YACS::StatesForNode getEffectiveState () const
 Return the node state in the context of its father. More...
 
virtual YACS::StatesForNode getEffectiveState (const Node *) const
 Return the effective state of a node in the context of this one (its father) More...
 
std::string getColorState (YACS::StatesForNode state) const
 Return the color associated to a state. More...
 
InGategetInGate ()
 
OutGategetOutGate ()
 
const std::string & getName () const
 
void setName (const std::string &name)
 Change the name of the node. More...
 
ComposedNodegetFather () const
 
const std::string getId () const
 
bool exIsControlReady () const
 
std::list< Node * > getOutNodes () const
 
virtual void writeDot (std::ostream &os) const
 Dump to the input stream a dot representation of the node. More...
 
virtual void exFailedState ()
 Notify this node that its execution has failed. More...
 
virtual void exDisabledState ()
 Notify this node that it has been disabled. More...
 
std::list< InPort * > getSetOfInPort () const
 
std::list< OutPort * > getSetOfOutPort () const
 
virtual std::set< InputPort * > edGetSetOfUnitializedInputPort () const
 Becomes deprecated soon. Replaced by ComposedNode::CheckConsistency. More...
 
virtual bool edAreAllInputPortInitialized () const
 Becomes deprecated soon. Replaced by ComposedNode::CheckConsistency. More...
 
InPortgetInPort (const std::string &name) const throw (Exception)
 
InPropertyPortgetInPropertyPort () const throw (Exception)
 
virtual OutPortgetOutPort (const std::string &name) const throw (Exception)
 
std::list< ComposedNode * > getAllAscendanceOf (ComposedNode *levelToStop=0) const
 
bool operator> (const Node &other) const
 
bool operator< (const Node &other) const
 
std::string getImplementation () const
 
virtual ComposedNodegetRootNode () const throw (Exception)
 
virtual void setProperty (const std::string &name, const std::string &value)
 
virtual std::string getProperty (const std::string &name)
 
std::map< std::string,
std::string > 
getProperties ()
 
std::map< std::string,
std::string > 
getPropertyMap ()
 
virtual void setProperties (std::map< std::string, std::string > properties)
 
virtual ProcgetProc ()
 
virtual const ProcgetProc () const
 
std::string getQualifiedName () const
 same as Node::getName() in most cases, but differs for children of switch More...
 
int getNumId ()
 return node instance identifiant, unique for each node instance More...
 
std::vector< std::pair
< std::string, int > > 
getDPLScopeInfo (ComposedNode *gfn)
 
virtual void applyDPLScope (ComposedNode *gfn)
 
virtual void sendEvent (const std::string &event)
 emit notification to all observers registered with the dispatcher More...
 
virtual void sendEvent2 (const std::string &event, void *something)
 emit notification to all observers registered with the dispatcher More...
 
virtual std::string getErrorDetails () const
 
virtual void setErrorDetails (const std::string &error)
 
virtual void modified ()
 Sets Node in modified state and its father if it exists. More...
 
virtual int isModified ()
 
virtual int isValid ()
 indicates if the node is valid (returns 1) or not (returns 0) More...
 
virtual std::string getErrorReport ()
 returns a string that contains an error report if the node is in error More...
 
virtual std::string getContainerLog ()
 returns a string that contains the name of the container log file if it exists More...
 
virtual void cleanNodes ()
 Clean the node in case of not clean exit. More...
 
- Public Member Functions inherited from YACS::ENGINE::Task
virtual ~Task ()
 

Static Public Attributes

static const char KIND [] ="DistPython"
 
static const char IMPL_NAME [] ="Python"
 
static const char SALOME_CONTAINER_METHOD_IDL [] ="createPyNode"
 

Protected Member Functions

NodesimpleClone (ComposedNode *father, bool editionOnly) const
 

Protected Attributes

PyObject * _context
 
PyObject * _pyfuncSer
 
PyObject * _pyfuncUnser
 
Engines::PyNode_var _pynode
 

Private Member Functions

void initMySelf ()
 
void dealException (CORBA::Exception *exc, const char *method, const char *ref)
 

Additional Inherited Members

- Static Public Member Functions inherited from YACS::ENGINE::Node
static std::string getStateName (YACS::StatesForNode state)
 Return the name of a state. More...
 
- Public Attributes inherited from YACS::ENGINE::Node
YACS::Colour _colour
 
- Static Protected Member Functions inherited from YACS::ENGINE::ElementaryNode
template<class PORT >
static void edRemovePortTypedFromSet (PORT *port, std::list< PORT * > &setOfPorts) throw (Exception)
 
template<class PORT >
static bool isPortNameAlreadyExist (const std::string &portName, const std::list< PORT * > &setOfPorts)
 
- Static Protected Attributes inherited from YACS::ENGINE::Node
static const char SEP_CHAR_IN_PORT [] ="."
 
static int _total = 0
 

Detailed Description

Definition at line 44 of file DistributedPythonNode.hxx.

Constructor & Destructor Documentation

DistributedPythonNode::DistributedPythonNode ( const std::string &  name)

Definition at line 44 of file DistributedPythonNode.cxx.

References initMySelf().

Referenced by createNode().

45 {
46  initMySelf();
47 }
DistributedPythonNode::DistributedPythonNode ( const DistributedPythonNode other,
ComposedNode father 
)

Definition at line 49 of file DistributedPythonNode.cxx.

References initMySelf().

49  :ServerNode(other,father),_context(0),_pyfuncSer(0),_pyfuncUnser(0)
50 {
51  initMySelf();
52 }
DistributedPythonNode::~DistributedPythonNode ( )

Definition at line 54 of file DistributedPythonNode.cxx.

References _context.

55 {
56  AutoGIL agil;
57  Py_DECREF(_context);
58 }

Member Function Documentation

ServerNode * DistributedPythonNode::createNode ( const std::string &  name) const
virtual
void DistributedPythonNode::dealException ( CORBA::Exception *  exc,
const char *  method,
const char *  ref 
)
private

Definition at line 284 of file DistributedPythonNode.cxx.

References YACS::ENGINE::Node::_errorDetails, DEBTRACE, and YACS::ENGINE::ElementaryNode::getErrorDetails().

285 {
286  if( exc )
287  {
288  DEBTRACE( "An exception was thrown!" );
289  DEBTRACE( "The raised exception is of Type:" << exc->_name() );
290 
291  CORBA::SystemException* sysexc;
292  sysexc=CORBA::SystemException::_downcast(exc);
293  if(sysexc != NULL)
294  {
295  // It's a SystemException
296  DEBTRACE( "minor code: " << sysexc->minor() );
297  DEBTRACE( "completion code: " << sysexc->completed() );
298  std::string text="Execution problem: ";
299  std::string excname=sysexc->_name();
300  if(excname == "BAD_OPERATION")
301  {
302  text=text+"bad operation detected";
303  }
304  else if(excname == "MARSHAL" && sysexc->minor() == omni::MARSHAL_PassEndOfMessage)
305  {
306  text=text+"probably an error in arguments of service '" + method + "' from component '" +ref+ "'";
307  }
308  else if(excname == "COMM_FAILURE" && sysexc->minor() == omni::COMM_FAILURE_UnMarshalResults)
309  {
310  text=text+"probably an error in output arguments of service '" + method + "' from component '" +ref+ "'";
311  }
312  else if(excname == "COMM_FAILURE" && sysexc->minor() == omni::COMM_FAILURE_UnMarshalArguments)
313  {
314  text=text+"probably an error in input arguments of service '" + method + "' from component '" +ref+ "'";
315  }
316  else if(excname == "COMM_FAILURE" && sysexc->minor() == omni::COMM_FAILURE_WaitingForReply)
317  {
318  text=text+"probably an error in input arguments of service '" + method + "' from component '" +ref+ "'";
319  }
320  else
321  {
322  DEBTRACE(sysexc->NP_minorString() );
323  text=text+"System Exception "+ excname;
324  }
325  _errorDetails=text;
326  throw Exception(text);
327  }
328 
329  // Not a System Exception
330  CORBA::UnknownUserException* userexc;
331  userexc=CORBA::UnknownUserException::_downcast(exc);
332  if(userexc != NULL)
333  {
334  CORBA::Any anyExcept = userexc->exception();
335 
336  const SALOME::SALOME_Exception* salexc;
337  if(anyExcept >>= salexc)
338  {
339  DEBTRACE("SALOME_Exception: "<< salexc->details.sourceFile);
340  DEBTRACE("SALOME_Exception: "<<salexc->details.lineNumber);
341  _errorDetails=salexc->details.text;
342  throw Exception("Execution problem: Salome Exception occurred" + getErrorDetails() );
343  }
344  std::string msg="Execution problem: User Exception occurred";
345  _errorDetails=msg;
346  throw Exception(msg);
347  }
348  std::string msg="Execution problem";
349  _errorDetails=msg;
350  throw Exception(msg);
351  }
352 }
void DistributedPythonNode::execute ( )
virtual

Implements YACS::ENGINE::Task.

Definition at line 161 of file DistributedPythonNode.cxx.

References YACS::ENGINE::Node::_errorDetails, _pyfuncSer, _pyfuncUnser, _pynode, YACS::ENGINE::ElementaryNode::_setOfInputPort, YACS::ENGINE::ElementaryNode::_setOfOutputPort, DEBTRACE, YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::InlineFuncNode::getFname(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::Node::getName(), YACS::ENGINE::ElementaryNode::getNumberOfInputPorts(), YACS::ENGINE::ElementaryNode::getNumberOfOutputPorts(), YACS::ENGINE::InputPyPort::getPyObj(), CORBAEngineTest::i, YACS::ENGINE::TypeCode::kind(), p, YACS::ENGINE::OutputPyPort::put(), YACS::Exception::what(), and YACSTRACE.

162 {
163  YACSTRACE(1,"+++++++++++++++++ DistributedPythonNode::execute: " << getName() << " " << getFname() << " +++++++++++++++++" );
165  PyObject* ob;
166  if(!_pyfuncSer)
167  throw Exception("DistributedPythonNode badly loaded");
168  Engines::pickledArgs *serializationInputCorba(0);
169  PyObject *args(0);
170  {
171  AutoGIL agil;
172 
173  DEBTRACE( "---------------DistributedPythonNode::inputs---------------" );
174  args = PyTuple_New(getNumberOfInputPorts()) ;
175  int pos=0;
176  for(list<InputPort *>::iterator iter2 = _setOfInputPort.begin(); iter2 != _setOfInputPort.end(); iter2++,pos++)
177  {
178  InputPyPort *p=(InputPyPort *)*iter2;
179  ob=p->getPyObj();
180  Py_INCREF(ob);
181  PyTuple_SetItem(args,pos,ob);
182  }
183  PyObject *serializationInput=PyObject_CallObject(_pyfuncSer,args);
184  std::string serializationInputC=PyString_AsString(serializationInput);
185  serializationInputCorba=new Engines::pickledArgs;
186  int len=serializationInputC.length();
187  serializationInputCorba->length(serializationInputC.length());
188  for(int i=0;i<serializationInputC.length();i++)
189  (*serializationInputCorba)[i]=serializationInputC[i];
190  Py_DECREF(serializationInput);
191  }
192  //serializationInputCorba[serializationInputC.length()]='\0';
193  DEBTRACE( "-----------------DistributedPythonNode starting remote python invocation-----------------" );
194  Engines::pickledArgs *resultCorba;
195  try
196  {
197  resultCorba=_pynode->execute(getFname().c_str(),*serializationInputCorba);
198  }
199  catch(...)
200  {
201  std::string msg="Exception on remote python invocation";
202  _errorDetails=msg;
203  throw Exception(msg);
204  }
205  DEBTRACE( "-----------------DistributedPythonNode end of remote python invocation-----------------" );
206  //
207  delete serializationInputCorba;
208  char *resultCorbaC=new char[resultCorba->length()+1];
209  resultCorbaC[resultCorba->length()]='\0';
210  for(int i=0;i<resultCorba->length();i++)
211  resultCorbaC[i]=(*resultCorba)[i];
212  delete resultCorba;
213  {
214  AutoGIL agil;
215  args = PyTuple_New(1);
216  PyObject* resultPython=PyString_FromString(resultCorbaC);
217  delete [] resultCorbaC;
218  PyTuple_SetItem(args,0,resultPython);
219  PyObject *finalResult=PyObject_CallObject(_pyfuncUnser,args);
220  DEBTRACE( "-----------------DistributedPythonNode::outputs-----------------" );
221  int nres=1;
222  if(finalResult == Py_None)
223  nres=0;
224  else if(PyTuple_Check(finalResult))
225  nres=PyTuple_Size(finalResult);
226 
227  if(getNumberOfOutputPorts() != nres)
228  {
229  std::string msg="Number of output arguments : Mismatch between definition and execution";
230  Py_DECREF(finalResult);
231  _errorDetails=msg;
232  throw Exception(msg);
233  }
234  try
235  {
236  int pos(0);
237  for(list<OutputPort *>::iterator iter = _setOfOutputPort.begin(); iter != _setOfOutputPort.end(); iter++, pos++)
238  {
239  OutputPyPort *p=(OutputPyPort *)*iter;
240  DEBTRACE( "port name: " << p->getName() );
241  DEBTRACE( "port kind: " << p->edGetType()->kind() );
242  DEBTRACE( "port pos : " << pos );
243  if(PyTuple_Check(finalResult))ob=PyTuple_GetItem(finalResult,pos) ;
244  else ob=finalResult;
245  DEBTRACE( "ob refcnt: " << ob->ob_refcnt );
246  p->put(ob);
247  }
248  }
249  catch(ConversionException& ex)
250  {
251  Py_DECREF(finalResult);
252  _errorDetails=ex.what();
253  throw;
254  }
255  }
256  DEBTRACE( "++++++++++++++ End DistributedPythonNode::execute: " << getName() << " ++++++++++++++++++++" );
257 }
std::string DistributedPythonNode::getEffectiveKindOfServer ( ) const
virtual

this method returns the type of container expected

Implements YACS::ENGINE::ServerNode.

Definition at line 259 of file DistributedPythonNode.cxx.

260 {
261  return "Salome";
262 }
std::string DistributedPythonNode::getKind ( ) const

this method returns the type of input/output expected

not a bug : this is to use classical python port translators.

Definition at line 264 of file DistributedPythonNode.cxx.

References YACS::ENGINE::PythonNode::KIND.

265 {
267  return PythonNode::KIND;
268 }
void DistributedPythonNode::initMySelf ( )
private

Definition at line 277 of file DistributedPythonNode.cxx.

References _context, YACS::ENGINE::Node::_implementation, and IMPL_NAME.

Referenced by DistributedPythonNode().

278 {
280  AutoGIL agil;
281  _context=PyDict_New();
282 }
void DistributedPythonNode::load ( )
virtual

Reimplemented from YACS::ENGINE::ServerNode.

Definition at line 60 of file DistributedPythonNode.cxx.

References YACS::ENGINE::InlineNode::_container, _context, YACS::ENGINE::Node::_errorDetails, _pyfuncSer, _pyfuncUnser, _pynode, YACS::ENGINE::SalomeContainerTmpForHP::BuildFrom(), DEBTRACE, YACS::ENGINE::SalomeContainer::getContainerPtr(), YACS::ENGINE::Node::getName(), YACS::ENGINE::getSALOMERuntime(), YACS::ENGINE::InlineNode::getScript(), YACS::ENGINE::Container::isAlreadyStarted(), YACS::ENGINE::ServerNode::load(), and YACS::ENGINE::newPyStdOut().

61 {
62  bool isContAlreadyStarted(false);
63  if(_container)
64  isContAlreadyStarted=_container->isAlreadyStarted(this);
66  {
67  AutoGIL agil;
68  if( PyDict_SetItemString( _context, "__builtins__", getSALOMERuntime()->getBuiltins() ))
69  {
70  stringstream msg;
71  msg << "Impossible to set builtins" << __FILE__ << ":" << __LINE__;
72  _errorDetails=msg.str();
73  throw Exception(msg.str());
74  }
75  const char picklizeScript[]="import cPickle\ndef pickleForDistPyth2009(*args,**kws):\n return cPickle.dumps((args,kws),-1)\n\ndef unPickleForDistPyth2009(st):\n args=cPickle.loads(st)\n return args\n";
76  PyObject *res=PyRun_String(picklizeScript,Py_file_input,_context,_context);
77  if(res == NULL)
78  {
79  _errorDetails="";
80  PyObject* new_stderr = newPyStdOut(_errorDetails);
81  PySys_SetObject((char*)"stderr", new_stderr);
82  PyErr_Print();
83  PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
84  Py_DECREF(new_stderr);
85  throw Exception("Error during execution");
86  return;
87  }
88  Py_DECREF(res);
89  _pyfuncSer=PyDict_GetItemString(_context,"pickleForDistPyth2009");
90  _pyfuncUnser=PyDict_GetItemString(_context,"unPickleForDistPyth2009");
91  if(_pyfuncSer == NULL)
92  {
93  _errorDetails="";
94  PyObject* new_stderr = newPyStdOut(_errorDetails);
95  PySys_SetObject((char*)"stderr", new_stderr);
96  PyErr_Print();
97  PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
98  Py_DECREF(new_stderr);
99  throw Exception("Error during execution");
100  }
101  if(_pyfuncUnser == NULL)
102  {
103  _errorDetails="";
104  PyObject* new_stderr = newPyStdOut(_errorDetails);
105  PySys_SetObject((char*)"stderr", new_stderr);
106  PyErr_Print();
107  PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
108  Py_DECREF(new_stderr);
109  throw Exception("Error during execution");
110  }
111 
112  Engines::Container_var objContainer=Engines::Container::_nil();
113  if(!_container)
114  throw Exception("No container specified !");
115  SalomeContainer *containerCast0(dynamic_cast<SalomeContainer *>(_container));
116  SalomeHPContainer *containerCast1(dynamic_cast<SalomeHPContainer *>(_container));
117  if(containerCast0)
118  objContainer=containerCast0->getContainerPtr(this);
119  else if(containerCast1)
120  {
122  objContainer=tmpCont->getContainerPtr(this);
123  }
124  else
125  throw Exception("Unrecognized type of container ! Salome one is expected !");
126  if(CORBA::is_nil(objContainer))
127  throw Exception("Container corba pointer is NULL !");
128 
129  try
130  {
131  if(containerCast0 || !isContAlreadyStarted)
132  {
133  _pynode = objContainer->createPyNode(getName().c_str(),getScript().c_str());
134  }
135  else
136  {
137  Engines::PyNode_var dftPyScript(objContainer->getDefaultPyNode(getName().c_str()));
138  if(CORBA::is_nil(dftPyScript))
139  _pynode = objContainer->createPyNode(getName().c_str(),getScript().c_str());
140  else
141  _pynode = dftPyScript;
142  }
143  }
144  catch( const SALOME::SALOME_Exception& ex )
145  {
146  std::string msg="Exception on remote python node creation ";
147  msg += '\n';
148  msg += ex.details.text.in();
149  _errorDetails=msg;
150  throw Exception(msg);
151  }
152 
153  if(CORBA::is_nil(_pynode))
154  throw Exception("In DistributedPythonNode the ref in NULL ! ");
155 
156 
157  DEBTRACE( "---------------End PyfuncSerNode::load function---------------" );
158  }
159 }
Node * DistributedPythonNode::simpleClone ( ComposedNode father,
bool  editionOnly 
) const
protectedvirtual

Implements YACS::ENGINE::Node.

Definition at line 39 of file DistributedPythonNode.cxx.

40 {
41  return new DistributedPythonNode(*this,father);
42 }
virtual std::string YACS::ENGINE::DistributedPythonNode::typeName ( )
inlinevirtual

Reimplemented from YACS::ENGINE::ServerNode.

Definition at line 59 of file DistributedPythonNode.hxx.

59 {return "YACS__ENGINE__DistributedPythonNode";}

Member Data Documentation

PyObject* YACS::ENGINE::DistributedPythonNode::_context
protected

Definition at line 68 of file DistributedPythonNode.hxx.

Referenced by initMySelf(), load(), and ~DistributedPythonNode().

PyObject* YACS::ENGINE::DistributedPythonNode::_pyfuncSer
protected

Definition at line 69 of file DistributedPythonNode.hxx.

Referenced by execute(), and load().

PyObject* YACS::ENGINE::DistributedPythonNode::_pyfuncUnser
protected

Definition at line 70 of file DistributedPythonNode.hxx.

Referenced by execute(), and load().

Engines::PyNode_var YACS::ENGINE::DistributedPythonNode::_pynode
protected

Definition at line 71 of file DistributedPythonNode.hxx.

Referenced by execute(), and load().

const char DistributedPythonNode::IMPL_NAME ="Python"
static

Definition at line 65 of file DistributedPythonNode.hxx.

Referenced by initMySelf().

const char DistributedPythonNode::KIND ="DistPython"
static

Definition at line 64 of file DistributedPythonNode.hxx.

const char DistributedPythonNode::SALOME_CONTAINER_METHOD_IDL ="createPyNode"
static

Definition at line 66 of file DistributedPythonNode.hxx.


The documentation for this class was generated from the following files: