From ceb46f3f5e81cec00a1a833c42765f3300dcabb0 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Wed, 17 Sep 2014 14:09:03 +0200 Subject: [PATCH] Correction of bug that make the YACSContainer crash when container log is requested by GUI. --- src/runtime/PythonNode.cxx | 71 ++++++++++++++++++++------------------ src/runtime/PythonNode.hxx | 1 + 2 files changed, 38 insertions(+), 34 deletions(-) diff --git a/src/runtime/PythonNode.cxx b/src/runtime/PythonNode.cxx index 2ebeab40e..e8cbc2624 100644 --- a/src/runtime/PythonNode.cxx +++ b/src/runtime/PythonNode.cxx @@ -228,6 +228,41 @@ void PythonEntry::commonRemoteLoadPart3(InlineNode *reqNode, Engines::Container_ } } +std::string PythonEntry::GetContainerLog(const std::string& mode, Container *container, const Task *askingTask) +{ + if(mode=="local") + return ""; + + std::string msg; + try + { + SalomeContainer *containerCast(dynamic_cast(container)); + SalomeHPContainer *objContainer2(dynamic_cast(container)); + if(containerCast) + { + Engines::Container_var objContainer(containerCast->getContainerPtr(askingTask)); + CORBA::String_var logname = objContainer->logfilename(); + DEBTRACE(logname); + msg=logname; + std::string::size_type pos = msg.find(":"); + msg=msg.substr(pos+1); + } + else if(objContainer2) + { + msg="Remote PythonNode is on HP Container : no log because no info of the location by definition of HP Container !"; + } + else + { + msg="Not implemented yet for container log for that type of container !"; + } + } + catch(...) + { + msg = "Container no longer reachable"; + } + return msg; +} + void PythonEntry::commonRemoteLoad(InlineNode *reqNode) { commonRemoteLoadPart1(reqNode); @@ -585,23 +620,7 @@ void PythonNode::executeLocal() std::string PythonNode::getContainerLog() { - if(_mode=="local")return ""; - - std::string msg; - try - { - Engines::Container_var objContainer=((SalomeContainer*)_container)->getContainerPtr(this); - CORBA::String_var logname = objContainer->logfilename(); - DEBTRACE(logname); - msg=logname; - std::string::size_type pos = msg.find(":"); - msg=msg.substr(pos+1); - } - catch(...) - { - msg = "Container no longer reachable"; - } - return msg; + return PythonEntry::GetContainerLog(_mode,_container,this); } void PythonNode::shutdown(int level) @@ -1147,23 +1166,7 @@ PyFuncNode* PyFuncNode::cloneNode(const std::string& name) std::string PyFuncNode::getContainerLog() { - if(_mode=="local")return ""; - - std::string msg; - try - { - Engines::Container_var objContainer=((SalomeContainer*)_container)->getContainerPtr(this); - CORBA::String_var logname = objContainer->logfilename(); - DEBTRACE(logname); - msg=logname; - std::string::size_type pos = msg.find(":"); - msg=msg.substr(pos+1); - } - catch(...) - { - msg = "Container no longer reachable"; - } - return msg; + return PythonEntry::GetContainerLog(_mode,_container,this); } void PyFuncNode::shutdown(int level) diff --git a/src/runtime/PythonNode.hxx b/src/runtime/PythonNode.hxx index 8eef66b47..c54232f2b 100644 --- a/src/runtime/PythonNode.hxx +++ b/src/runtime/PythonNode.hxx @@ -49,6 +49,7 @@ namespace YACS void commonRemoteLoadPart1(InlineNode *reqNode); Engines::Container_var commonRemoteLoadPart2(InlineNode *reqNode, bool& isInitializeRequested); void commonRemoteLoadPart3(InlineNode *reqNode, Engines::Container_ptr objContainer, bool isInitializeRequested); + static std::string GetContainerLog(const std::string& mode, Container *container, const Task *askingTask); protected: PyObject *_context; PyObject *_pyfuncSer; -- 2.39.2