]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
CCAR: add a message in case of error when loading a component.
authorcaremoli <caremoli>
Tue, 8 Sep 2009 17:29:16 +0000 (17:29 +0000)
committercaremoli <caremoli>
Tue, 8 Sep 2009 17:29:16 +0000 (17:29 +0000)
The dlerror output for dlopen plus the traceback for the import of the python module
The import_component python function now returns a string instead of a boolean.
If the string is empty, the import is OK.
The C++ code in container MPIContainer and ParallelContainer has been adapted.

17 files changed:
src/Container/Component_i.cxx
src/Container/Container_i.cxx
src/Container/SALOME_ComponentPy.py
src/Container/SALOME_Component_i.hxx
src/Container/SALOME_Container.cxx
src/Container/SALOME_Container.py
src/Container/SALOME_ContainerManager.cxx
src/Container/SALOME_ContainerManager.hxx
src/Container/SALOME_ContainerPy.py
src/Container/SALOME_Container_i.hxx
src/Container/SALOME_FileRef_i.cxx
src/Container/SALOME_FileRef_i.hxx
src/Container/Salome_file_i.cxx
src/Container/Salome_file_i.hxx
src/MPIContainer/MPIContainer_i.cxx
src/ParallelContainer/SALOME_ParallelContainerProxy_i.cxx
src/ParallelContainer/SALOME_ParallelContainer_i.cxx

index eca25186b7adba0c1940d81799eb7b847c2ca368..83ed0d557629c96e92a7fa8108317b8646ad04c4 100644 (file)
@@ -88,10 +88,10 @@ Engines_Component_i::Engines_Component_i():_myConnexionToRegistry(0), _notifSupp
 //=============================================================================
 
 Engines_Component_i::Engines_Component_i(CORBA::ORB_ptr orb,
-                                        PortableServer::POA_ptr poa, 
-                                        PortableServer::ObjectId * contId, 
-                                        const char *instanceName,
-                                        const char *interfaceName,
+                                         PortableServer::POA_ptr poa, 
+                                         PortableServer::ObjectId * contId, 
+                                         const char *instanceName,
+                                         const char *interfaceName,
                                          bool notif,
                                          bool regist ) :
   _instanceName(instanceName),
@@ -448,17 +448,17 @@ bool Engines_Component_i::Suspend_impl()
 #endif
     {
       if ( _Sleeping )
-       {
-         return false ;
-       }
+        {
+          return false ;
+        }
     else 
       {
 #ifndef WIN32
-       RetVal = Killer( _ThreadId ,SIGINT ) ;
+        RetVal = Killer( _ThreadId ,SIGINT ) ;
 #else
-       RetVal = Killer( *_ThreadId ,SIGINT ) ;
+        RetVal = Killer( *_ThreadId ,SIGINT ) ;
 #endif
-       //if ( RetVal ) _Sleeping = true;
+        //if ( RetVal ) _Sleeping = true;
 
       }
     }
@@ -495,12 +495,12 @@ bool Engines_Component_i::Resume_impl()
     {
     if ( _Sleeping ) 
       {
-       _Sleeping = false ;
-       RetVal = true ;
+        _Sleeping = false ;
+        RetVal = true ;
       }
     else
       {
-       RetVal = false ;
+        RetVal = false ;
       }
     }
   return RetVal ;
@@ -524,35 +524,35 @@ CORBA::Long Engines_Component_i::CpuUsed_impl()
 #else
       if ( pthread_self().p != _ThreadId->p )
 #endif
-       {
+        {
         if ( _Sleeping )
-         {
-         }
+          {
+          }
         else
-         {
-           // Get Cpu in the appropriate thread with that object !...
-           theEngines_Component = this ;
+          {
+            // Get Cpu in the appropriate thread with that object !...
+            theEngines_Component = this ;
 #ifndef WIN32
-           Killer( _ThreadId ,SIGUSR1 ) ;
+            Killer( _ThreadId ,SIGUSR1 ) ;
 #else
-           Killer( *_ThreadId ,SIGUSR11 ) ;
+            Killer( *_ThreadId ,SIGUSR11 ) ;
 #endif
-         }
+          }
         cpu = _ThreadCpuUsed ;
-       }
+        }
       else
-       {
-         _ThreadCpuUsed = CpuUsed() ;
-         cpu = _ThreadCpuUsed ;
-         // cout << pthread_self() << " Engines_Component_i::CpuUsed_impl "
-         //      << _serviceName << " " << cpu << endl ;
+        {
+          _ThreadCpuUsed = CpuUsed() ;
+          cpu = _ThreadCpuUsed ;
+          // cout << pthread_self() << " Engines_Component_i::CpuUsed_impl "
+          //      << _serviceName << " " << cpu << endl ;
       }
     }
     else 
       {
-       cpu = _ThreadCpuUsed ;
-       // cout << pthread_self() << " Engines_Component_i::CpuUsed_impl "
-       //      << _serviceName << " " << cpu<< endl ;
+        cpu = _ThreadCpuUsed ;
+        // cout << pthread_self() << " Engines_Component_i::CpuUsed_impl "
+        //      << _serviceName << " " << cpu<< endl ;
       }
     }
   else
@@ -623,10 +623,10 @@ void Engines_Component_i::beginService(const char *serviceName)
 {
 #ifndef WIN32
   MESSAGE(pthread_self() << "Send BeginService notification for " <<serviceName
-         << endl << "Component instance : " << _instanceName << endl << endl);
+          << endl << "Component instance : " << _instanceName << endl << endl);
 #else
   MESSAGE(pthread_self().p << "Send BeginService notification for " <<serviceName
-         << endl << "Component instance : " << _instanceName << endl << endl);
+          << endl << "Component instance : " << _instanceName << endl << endl);
 #endif
 #ifndef WIN32
   _ThreadId = pthread_self() ;
@@ -663,26 +663,26 @@ void Engines_Component_i::beginService(const char *serviceName)
     {
       std::string cle((*it).first);
       if ((*it).second.type()->kind() == CORBA::tk_string)
-       {
-         const char* value;
-         (*it).second >>= value;
-         // ---todo: replace __GNUC__ test by an autoconf macro AC_CHECK_FUNC.
+        {
+          const char* value;
+          (*it).second >>= value;
+          // ---todo: replace __GNUC__ test by an autoconf macro AC_CHECK_FUNC.
 #if defined __GNUC__
-//       int ret = setenv(cle.c_str(), value, overwrite);
-         setenv(cle.c_str(), value, overwrite);
+//          int ret = setenv(cle.c_str(), value, overwrite);
+          setenv(cle.c_str(), value, overwrite);
 #else
-         //CCRT porting : setenv not defined in stdlib.h
-         std::string s(cle);
-         s+='=';
-         s+=value;
-         // char* cast because 1st arg of linux putenv function
-         // is not a const char* !
-//       int ret=putenv((char *)s.c_str());
-         putenv((char *)s.c_str());
-         //End of CCRT porting
+          //CCRT porting : setenv not defined in stdlib.h
+          std::string s(cle);
+          s+='=';
+          s+=value;
+          // char* cast because 1st arg of linux putenv function
+          // is not a const char* !
+//          int ret=putenv((char *)s.c_str());
+          putenv((char *)s.c_str());
+          //End of CCRT porting
 #endif
-         MESSAGE("--- setenv: "<<cle<<" = "<< value);
-       }
+          MESSAGE("--- setenv: "<<cle<<" = "<< value);
+        }
     }
 }
 
@@ -699,11 +699,11 @@ void Engines_Component_i::endService(const char *serviceName)
 
 #ifndef WIN32
   MESSAGE(pthread_self() << " Send EndService notification for " << serviceName
-         << endl << " Component instance : " << _instanceName << " StartUsed "
+          << endl << " Component instance : " << _instanceName << " StartUsed "
           << _StartUsed << " _ThreadCpuUsed "<< _ThreadCpuUsed << endl <<endl);
 #else
   MESSAGE(pthread_self().p << " Send EndService notification for " << serviceName
-         << endl << " Component instance : " << _instanceName << " StartUsed "
+          << endl << " Component instance : " << _instanceName << " StartUsed "
     << _StartUsed << " _ThreadCpuUsed "<< _ThreadCpuUsed << endl <<endl);
 #endif
   _ThreadId = 0 ;
@@ -746,41 +746,41 @@ bool Engines_Component_i::Killer( pthread_t ThreadId , int signum )
 #endif
     {
       if ( signum == 0 )
-       {
-         if ( pthread_cancel( ThreadId ) )
-           {
-             perror("Killer pthread_cancel error") ;
-             return false ;
-           }
-         else
-           {
+        {
+          if ( pthread_cancel( ThreadId ) )
+            {
+              perror("Killer pthread_cancel error") ;
+              return false ;
+            }
+          else
+            {
 #ifndef WIN32
-             MESSAGE(pthread_self() << "Killer : ThreadId " << ThreadId
-                     << " pthread_canceled") ;
+              MESSAGE(pthread_self() << "Killer : ThreadId " << ThreadId
+                      << " pthread_canceled") ;
 #else
         MESSAGE(pthread_self().p << "Killer : ThreadId " << ThreadId.p
-                     << " pthread_canceled") ;
+                      << " pthread_canceled") ;
 #endif
-           }
-       }
+            }
+        }
       else
-       {
-         if ( pthread_kill( ThreadId , signum ) == -1 )
-           {
-             perror("Killer pthread_kill error") ;
-             return false ;
-           }
-         else 
-           {
+        {
+          if ( pthread_kill( ThreadId , signum ) == -1 )
+            {
+              perror("Killer pthread_kill error") ;
+              return false ;
+            }
+          else 
+            {
 #ifndef WIN32
         MESSAGE(pthread_self() << "Killer : ThreadId " << ThreadId
-                     << " pthread_killed(" << signum << ")") ;
+                      << " pthread_killed(" << signum << ")") ;
 #else
         MESSAGE(pthread_self().p << "Killer : ThreadId " << ThreadId.p
-                     << " pthread_killed(" << signum << ")") ;
+                      << " pthread_killed(" << signum << ")") ;
 #endif
-           }
-       }
+            }
+        }
     }
   return true ;
 }
@@ -824,10 +824,10 @@ long Engines_Component_i::CpuUsed()
   if ( _ThreadId || _Executed )
     {
       if ( getrusage( RUSAGE_SELF , &usage ) == -1 )
-       {
-         perror("Engines_Component_i::CpuUsed") ;
-         return 0 ;
-       }
+        {
+          perror("Engines_Component_i::CpuUsed") ;
+          return 0 ;
+        }
       cpu = usage.ru_utime.tv_sec - _StartUsed ;
       // cout << pthread_self() << " Engines_Component_i::CpuUsed " << " "
       //      << _serviceName   << usage.ru_utime.tv_sec << " - " << _StartUsed
@@ -840,7 +840,7 @@ long Engines_Component_i::CpuUsed()
       //      << _StartUsed << endl ;
     }
 #else
-       // NOT implementet yet
+        // NOT implementet yet
 #endif
 
 
@@ -871,7 +871,7 @@ void Engines_Component_i::CancelThread()
 //=============================================================================
 
 void Engines_Component_i::sendMessage(const char *event_type,
-                                     const char *message)
+                                      const char *message)
 {
     _notifSupplier->Send(_graphName.c_str(), _nodeName.c_str(), event_type, message);
 }
@@ -897,8 +897,8 @@ string Engines_Component_i::GetDynLibraryName(const char *componentName)
 //=============================================================================
 
 Engines::TMPFile* Engines_Component_i::DumpPython(CORBA::Object_ptr theStudy, 
-                                                 CORBA::Boolean isPublished, 
-                                                 CORBA::Boolean& isValidScript)
+                                                  CORBA::Boolean isPublished, 
+                                                  CORBA::Boolean& isValidScript)
 {
   const char* aScript = "def RebuildData(theStudy): pass";
   char* aBuffer = new char[strlen(aScript)+1];
@@ -912,7 +912,7 @@ Engines::TMPFile* Engines_Component_i::DumpPython(CORBA::Object_ptr theStudy,
 
 Engines::Salome_file_ptr 
 Engines_Component_i::getInputFileToService(const char* service_name, 
-                                          const char* Salome_file_name) 
+                                           const char* Salome_file_name) 
 {
   // Try to find the service, if it doesn't exist, we throw an exception.
   _Service_file_map_it = _Input_Service_file_map.find(service_name);
@@ -939,7 +939,7 @@ Engines_Component_i::getInputFileToService(const char* service_name,
 
 Engines::Salome_file_ptr 
 Engines_Component_i::setInputFileToService(const char* service_name, 
-                                          const char* Salome_file_name) 
+                                           const char* Salome_file_name) 
 {
   // Try to find the service, if it doesn't exist, we add it.
   _Service_file_map_it = _Input_Service_file_map.find(service_name);
@@ -983,7 +983,7 @@ Engines_Component_i::checkInputFilesToService(const char* service_name)
 
 Engines::Salome_file_ptr 
 Engines_Component_i::getOutputFileToService(const char* service_name, 
-                                           const char* Salome_file_name) 
+                                            const char* Salome_file_name) 
 {
   // Try to find the service, if it doesn't exist, we throw an exception.
   _Service_file_map_it = _Output_Service_file_map.find(service_name);
@@ -1010,7 +1010,7 @@ Engines_Component_i::getOutputFileToService(const char* service_name,
 
 Engines::Salome_file_ptr 
 Engines_Component_i::setOutputFileToService(const char* service_name, 
-                                          const char* Salome_file_name) 
+                                           const char* Salome_file_name) 
 {
   // Try to find the service, if it doesn't exist, we add it.
   _Service_file_map_it = _Output_Service_file_map.find(service_name);
@@ -1063,8 +1063,8 @@ Engines_Component_i::checkOutputFilesToService(const char* service_name)
 //=============================================================================
 void
 Engines_Component_i::configureSalome_file(std::string service_name,
-                                         std::string file_port_name,
-                                         Salome_file_i * file) 
+                                          std::string file_port_name,
+                                          Salome_file_i * file) 
 {
   // By default this method does nothing
 }
index 065c5b4b55165398d5c8d36bbdc9f8766fad92c7..6db3ab07abd775d089b427cabb03bc4fc2fc98cc 100644 (file)
@@ -83,6 +83,9 @@ map<std::string, void *> Engines_Container_i::_library_map;
 map<std::string, void *> Engines_Container_i::_toRemove_map;
 omni_mutex Engines_Container_i::_numInstanceMutex ;
 
+int checkifexecutable(const std::string&);
+int findpathof(std::string&, const std::string&);
+
 /*! \class Engines_Container_i
  *  \brief C++ implementation of Engines::Container interface
  *
@@ -404,8 +407,8 @@ int findpathof(string& pth, const string& exe)
 {
   string path( getenv("PATH") );
   if ( path.size() == 0 )
-         return 0;
-       
+         return 0;
+       
   char path_spr =
 #ifdef WIN32
                   ';';
@@ -519,9 +522,11 @@ Engines_Container_i::load_component_Library(const char* componentName)
     return true;
   }
 
+  std::string retso="";
 #ifndef WIN32
   void* handle;
   handle = dlopen( impl_name.c_str() , RTLD_LAZY ) ;
+  if ( !handle )retso=dlerror();
 #else
   HINSTANCE handle;
   handle = LoadLibrary( impl_name.c_str() );
@@ -538,6 +543,7 @@ Engines_Container_i::load_component_Library(const char* componentName)
   // --- try import Python component
 
   INFOS("try import Python component "<<componentName);
+  std::string retpy;
   if (_isSupervContainer)
   {
     INFOS("Supervision Container does not support Python Component Engines");
@@ -556,12 +562,13 @@ Engines_Container_i::load_component_Library(const char* componentName)
     PyObject *result = PyObject_CallMethod(pyCont,
       (char*)"import_component",
       (char*)"s",componentName);
-    int ret= PyInt_AsLong(result);
+
+    retpy=PyString_AsString(result);
     Py_XDECREF(result);
-    SCRUTE(ret);
+    SCRUTE(retpy);
     Py_RELEASE_NEW_THREAD;
 
-    if (ret) // import possible: Python component
+    if (retpy=="") // import possible: Python component
     {
       _numInstanceMutex.lock() ; // lock to be alone (stl container write)
       _library_map[aCompName] = (void *)pyCont; // any non O value OK
@@ -578,7 +585,9 @@ Engines_Container_i::load_component_Library(const char* componentName)
 
   INFOS( "Impossible to load component: " << componentName );
   INFOS( "Can't load shared library: " << impl_name );
+  std::cerr << retso << std::endl;
   INFOS( "Can't import Python module: " << componentName );
+  std::cerr << retpy << std::endl;
   INFOS( "Can't execute program: " << executable );
   return false;
 }
index 1d5722ad937c450c49f66f53ac19ff19a09beec7..da1f89f15e11858164a95cc3352fb20dc25ec2fe 100755 (executable)
@@ -288,7 +288,7 @@ class SALOME_ComponentPy_i (Engines__POA.Component):
    
     def DumpPython(self, theStudy, isPublished):
         aBuffer = "def RebuildData(theStudy): pass\n\0"
-       return (aBuffer, 1)
+        return (aBuffer, 1)
 
     #-------------------------------------------------------------------------    
 
@@ -298,7 +298,7 @@ class SALOME_ComponentPy_i (Engines__POA.Component):
     #-------------------------------------------------------------------------    
 
     def hasObjectInfo(self):
-       return 0
+        return 0
 
     #-------------------------------------------------------------------------    
 
index a96756f4e39024385fddfc405a08ec0ad53360e6..b87f3212bf08693e5a39aab63822d4803be90f28 100644 (file)
@@ -55,18 +55,18 @@ class CONTAINER_EXPORT Engines_Component_i:
 public:
   Engines_Component_i();
   Engines_Component_i(CORBA::ORB_ptr orb,
-                     PortableServer::POA_ptr poa,
-                     PortableServer::ObjectId * contId, 
-                     const char *instanceName, 
-                     const char *interfaceName,
+                      PortableServer::POA_ptr poa,
+                      PortableServer::ObjectId * contId, 
+                      const char *instanceName, 
+                      const char *interfaceName,
                       bool notif = false,
                       bool regist = true);
   //Constructor for standalone component
   Engines_Component_i(CORBA::ORB_ptr orb,
-                     PortableServer::POA_ptr poa,
-                     Engines::Container_ptr container, 
-                     const char *instanceName, 
-                     const char *interfaceName,
+                      PortableServer::POA_ptr poa,
+                      Engines::Container_ptr container, 
+                      const char *instanceName, 
+                      const char *interfaceName,
                       bool notif = false,
                       bool regist = true);
 
index cdcfc64a9a8a6a23991c25892453144f51623e02..c4a1e0dba4079d9f644a07dd36b20736668644d1 100644 (file)
@@ -200,7 +200,10 @@ int main(int argc, char* argv[])
       if (!isSupervContainer)
       {
         PyGILState_Ensure();
-        //Delete python container that destroy orb from python (pyCont._orb.destroy())
+        //Destroy orb from python (for chasing memory leaks)
+        //PyRun_SimpleString("from omniORB import CORBA");
+        //PyRun_SimpleString("orb=CORBA.ORB_init([''], CORBA.ORB_ID)");
+        //PyRun_SimpleString("orb.destroy()");
         Py_Finalize();
       }
       else
@@ -235,9 +238,6 @@ int main(int argc, char* argv[])
   #endif
 #endif  
 
-  //END_OF(argv[0]);
-  //LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance();
-  //bp1->deleteInstance(bp1);
   return 0 ;
 }
 
index 1a92f6b5442349cda21e407bec7a9372ad731bd8..73ba33123249a48e5c8f6377e933a8d727f9e075 100644 (file)
@@ -46,7 +46,7 @@ from launchConfigureParser import verbose
 
 #=============================================================================
 
-#define an implementation of the container interface
+#define an implementation of the container interface for embedding in Container implemented in C++
 
 class SALOME_Container_i:
     _orb = None
@@ -67,20 +67,17 @@ class SALOME_Container_i:
 
     #-------------------------------------------------------------------------
 
-    #def __del__(self ):
-    #  self._orb.destroy()
-
     def import_component(self, componentName):
         MESSAGE( "SALOME_Container_i::import_component" )
-        ret=0
+        ret=""
         try:
             if verbose(): print "try import ",componentName
             __import__(componentName)
             if verbose(): print "import ",componentName," successful"
-            ret=1
         except:
+            import traceback
+            ret=traceback.format_exc(10)
             if verbose():
-              import traceback
               traceback.print_exc()
               print "import ",componentName," not possible"
         return ret
index f0a5a04a97600ce625469738c23eb7cc5608ce57..d1e401c853054a5c470af64956a614c57c651819 100644 (file)
@@ -168,28 +168,28 @@ void SALOME_ContainerManager::ShutdownContainers()
     {
       try
       {
-       SCRUTE((*iter));
-       CORBA::Object_var obj=_NS->Resolve((*iter).c_str());
-       Engines::Container_var cont=Engines::Container::_narrow(obj);
-       if(!CORBA::is_nil(cont))
-       {
-         MESSAGE("ShutdownContainers: " << (*iter));
-         cont->Shutdown();
-       }
-       else 
-         MESSAGE("ShutdownContainers: no container ref for " << (*iter));
+        SCRUTE((*iter));
+        CORBA::Object_var obj=_NS->Resolve((*iter).c_str());
+        Engines::Container_var cont=Engines::Container::_narrow(obj);
+        if(!CORBA::is_nil(cont))
+        {
+          MESSAGE("ShutdownContainers: " << (*iter));
+          cont->Shutdown();
+        }
+        else 
+          MESSAGE("ShutdownContainers: no container ref for " << (*iter));
       }
       catch(CORBA::SystemException& e)
       {
-       INFOS("CORBA::SystemException ignored : " << e);
+        INFOS("CORBA::SystemException ignored : " << e);
       }
       catch(CORBA::Exception&)
       {
-       INFOS("CORBA::Exception ignored.");
+        INFOS("CORBA::Exception ignored.");
       }
       catch(...)
       {
-       INFOS("Unknown exception ignored.");
+        INFOS("Unknown exception ignored.");
       }
     }
   }
@@ -648,12 +648,12 @@ SALOME_ContainerManager::StartParallelContainer(const Engines::MachineParameters
       // Il faut tuer le proxy
       try 
       {
-       Engines::Container_var proxy = Engines::Container::_narrow(container_proxy);
-       proxy->Shutdown();
+        Engines::Container_var proxy = Engines::Container::_narrow(container_proxy);
+        proxy->Shutdown();
       }
       catch (...)
       {
-       INFOS("[StartParallelContainer] Exception catched from proxy Shutdown...");
+        INFOS("[StartParallelContainer] Exception catched from proxy Shutdown...");
       }
       return ret;
     }
@@ -671,34 +671,34 @@ SALOME_ContainerManager::StartParallelContainer(const Engines::MachineParameters
       obj = _NS->Resolve(containerNameInNS.c_str());
       if (CORBA::is_nil(obj)) 
       {
-       INFOS("[StartParallelContainer] CONNECTION FAILED From Naming Service !");
-       INFOS("[StartParallelContainer] Container name is " << containerNameInNS);
-       return ret;
+        INFOS("[StartParallelContainer] CONNECTION FAILED From Naming Service !");
+        INFOS("[StartParallelContainer] Container name is " << containerNameInNS);
+        return ret;
       }
       try
       {
-       MESSAGE("[StartParallelContainer] Deploying node : " << container_node_name);
-       PaCO::InterfaceParallel_var node = PaCO::InterfaceParallel::_narrow(obj);
-       node->deploy();
-       MESSAGE("[StartParallelContainer] node " << container_node_name << " is deployed");
+        MESSAGE("[StartParallelContainer] Deploying node : " << container_node_name);
+        PaCO::InterfaceParallel_var node = PaCO::InterfaceParallel::_narrow(obj);
+        node->deploy();
+        MESSAGE("[StartParallelContainer] node " << container_node_name << " is deployed");
       }
       catch(CORBA::SystemException& e)
       {
-       INFOS("[StartParallelContainer] Exception in deploying node : " << containerNameInNS);
-       INFOS("CORBA::SystemException : " << e);
-       return ret;
+        INFOS("[StartParallelContainer] Exception in deploying node : " << containerNameInNS);
+        INFOS("CORBA::SystemException : " << e);
+        return ret;
       }
       catch(CORBA::Exception& e)
       {
-       INFOS("[StartParallelContainer] Exception in deploying node : " << containerNameInNS);
-       INFOS("CORBA::Exception" << e);
-       return ret;
+        INFOS("[StartParallelContainer] Exception in deploying node : " << containerNameInNS);
+        INFOS("CORBA::Exception" << e);
+        return ret;
       }
       catch(...)
       {
-       INFOS("[StartParallelContainer] Exception in deploying node : " << containerNameInNS);
-       INFOS("Unknown exception !");
-       return ret;
+        INFOS("[StartParallelContainer] Exception in deploying node : " << containerNameInNS);
+        INFOS("Unknown exception !");
+        return ret;
       }
     }
 
@@ -764,9 +764,9 @@ SALOME_ContainerManager::StartParallelContainer(const Engines::MachineParameters
 //=============================================================================
 CORBA::Object_ptr 
 SALOME_ContainerManager::LaunchParallelContainer(const std::string& command, 
-                                                const Engines::MachineParameters& params,
-                                                const std::string& name,
-                                                SALOME_ContainerManager::actual_launch_machine_t & vect_machine)
+                                                 const Engines::MachineParameters& params,
+                                                 const std::string& name,
+                                                 SALOME_ContainerManager::actual_launch_machine_t & vect_machine)
 {
   CORBA::Object_ptr obj = CORBA::Object::_nil();
   std::string containerNameInNS;
@@ -817,17 +817,17 @@ SALOME_ContainerManager::LaunchParallelContainer(const std::string& command,
       INFOS("[LaunchParallelContainer]  Waiting for Parallel Container node " << containerNameInNS << " on " << theMachine);
       while (CORBA::is_nil(obj) && count) {
 #ifndef WIN32
-       sleep(1) ;
+        sleep(1) ;
 #else
-       Sleep(1000);
+        Sleep(1000);
 #endif
-       count-- ;
-       obj = _NS->Resolve(containerNameInNS.c_str());
+        count-- ;
+        obj = _NS->Resolve(containerNameInNS.c_str());
       }
       if (CORBA::is_nil(obj))
       {
-       INFOS("[LaunchParallelContainer] Launch of node failed (or not found) !");
-       return obj;
+        INFOS("[LaunchParallelContainer] Launch of node failed (or not found) !");
+        return obj;
       }
     }
   }
@@ -900,7 +900,7 @@ SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer
 {
   string command;
   int nbproc;
-         
+          
   if ( ! _isAppliSalomeDefined )
     command = BuildTempFileToLaunchRemoteContainer(machine, params);
 
@@ -931,21 +931,21 @@ SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer
         throw SALOME_Exception("Unknown protocol");
 
       if (resInfo.UserName != "")
-       {
-         command += resInfo.UserName;
-         command += "@";
-       }
+        {
+          command += resInfo.UserName;
+          command += "@";
+        }
 
       command += machine;
       command += " ";
 
       if (resInfo.AppliPath != "")
-       command += resInfo.AppliPath; // path relative to user@machine $HOME
+        command += resInfo.AppliPath; // path relative to user@machine $HOME
       else
-       {
-         ASSERT(getenv("APPLI"));
-         command += getenv("APPLI"); // path relative to user@machine $HOME
-       }
+        {
+          ASSERT(getenv("APPLI"));
+          command += getenv("APPLI"); // path relative to user@machine $HOME
+        }
 
       command += "/runRemote.sh ";
 
@@ -968,23 +968,23 @@ SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer
         }
 
       if(params.isMPI)
-       {
-         command += " mpirun -np ";
-         std::ostringstream o;
-         o << nbproc << " ";
-         command += o.str();
+        {
+          command += " mpirun -np ";
+          std::ostringstream o;
+          o << nbproc << " ";
+          command += o.str();
 #ifdef WITHLAM
-         command += "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
+          command += "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
 #elif defined(WITHOPENMPI)
-         if( getenv("OMPI_URI_FILE") == NULL )
-           command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
-         else{
-           command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
-           command += getenv("OMPI_URI_FILE");
-         }
-#endif 
-         command += " SALOME_MPIContainer ";
-       }
+          if( getenv("OMPI_URI_FILE") == NULL )
+            command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
+          else{
+            command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
+            command += getenv("OMPI_URI_FILE");
+          }
+#endif        
+          command += " SALOME_MPIContainer ";
+        }
       else
         command += " " +container_exe+ " ";
 
@@ -1040,7 +1040,7 @@ SALOME_ContainerManager::BuildCommandToLaunchLocalContainer
 #elif defined(WITHOPENMPI)
       //command += "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace ";
       if( getenv("OMPI_URI_FILE") == NULL )
-       command_file << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
+        command_file << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
       else
         {
           command_file << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
@@ -1246,10 +1246,10 @@ SALOME_ContainerManager::BuildTempFileToLaunchRemoteContainer
       tempOutputFile << "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
 #elif defined(WITHOPENMPI)
       if( getenv("OMPI_URI_FILE") == NULL )
-       tempOutputFile << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
+        tempOutputFile << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace";
       else{
-       tempOutputFile << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
-       tempOutputFile << getenv("OMPI_URI_FILE");
+        tempOutputFile << "-x PATH -x LD_LIBRARY_PATH -x OMNIORB_CONFIG -x SALOME_trace -ompi-server file:";
+        tempOutputFile << getenv("OMPI_URI_FILE");
       }
 #endif
     }
@@ -1332,9 +1332,9 @@ SALOME_ContainerManager::BuildTempFileToLaunchRemoteContainer
 //=============================================================================
 string 
 SALOME_ContainerManager::BuildCommandToLaunchParallelContainer(const std::string& exe_name,
-                                                              const Engines::MachineParameters& params,
-                                                              SALOME_ContainerManager::actual_launch_machine_t & vect_machine,
-                                                              const std::string proxy_hostname)
+                                                               const Engines::MachineParameters& params,
+                                                               SALOME_ContainerManager::actual_launch_machine_t & vect_machine,
+                                                               const std::string proxy_hostname)
 {
   // This method knows the differences between the proxy and the nodes.
   // nb_component_nodes is not used in the same way if it is a proxy or 
@@ -1387,14 +1387,14 @@ SALOME_ContainerManager::BuildCommandToLaunchParallelContainer(const std::string
     if (is_a_proxy)
     {
       machine_file_name = _ResManager->getMachineFile(hostname,
-                                                     1,
-                                                     parallelLib);
+                                                      1,
+                                                      parallelLib);
     }
     else
     {
       machine_file_name = _ResManager->getMachineFile(hostname, 
-                                                     params.nb_component_nodes,
-                                                     parallelLib);
+                                                      params.nb_component_nodes,
+                                                      parallelLib);
     }
     if (machine_file_name == "")
     {
@@ -1442,32 +1442,32 @@ SALOME_ContainerManager::BuildCommandToLaunchParallelContainer(const std::string
       std::string command_remote("");
       if (remote)
       {
-       std::string machine_name;
-       std::ifstream machine_file(machine_file_name.c_str());
-       std::getline(machine_file, machine_name);
-       MESSAGE("[BuildCommandToLaunchParallelContainer] machine file name extracted is " << machine_name)
-
-       // We want to launch a command like : 
-       // ssh user@machine distantPath/runRemote.sh hostNS portNS
-       const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(machine_name);
-       if (resInfo.Protocol == rsh)
-         command_remote = "rsh ";
-       else 
-         command_remote = "ssh ";
-       command_remote += resInfo.UserName;
-       command_remote += "@";
-       command_remote += machine_name;
-       command_remote += " ";
-       command_remote += resInfo.AppliPath; // path relative to user@machine $HOME
-       command_remote += "/runRemote.sh ";
-       ASSERT(getenv("NSHOST")); 
-       command_remote += getenv("NSHOST"); // hostname of CORBA name server
-       command_remote += " ";
-       ASSERT(getenv("NSPORT"));
-       command_remote += getenv("NSPORT"); // port of CORBA name server
-       command_remote += " ";
-
-       hostname = machine_name;
+        std::string machine_name;
+        std::ifstream machine_file(machine_file_name.c_str());
+        std::getline(machine_file, machine_name);
+        MESSAGE("[BuildCommandToLaunchParallelContainer] machine file name extracted is " << machine_name)
+
+        // We want to launch a command like : 
+        // ssh user@machine distantPath/runRemote.sh hostNS portNS
+        const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(machine_name);
+        if (resInfo.Protocol == rsh)
+          command_remote = "rsh ";
+        else 
+          command_remote = "ssh ";
+        command_remote += resInfo.UserName;
+        command_remote += "@";
+        command_remote += machine_name;
+        command_remote += " ";
+        command_remote += resInfo.AppliPath; // path relative to user@machine $HOME
+        command_remote += "/runRemote.sh ";
+        ASSERT(getenv("NSHOST")); 
+        command_remote += getenv("NSHOST"); // hostname of CORBA name server
+        command_remote += " ";
+        ASSERT(getenv("NSPORT"));
+        command_remote += getenv("NSPORT"); // port of CORBA name server
+        command_remote += " ";
+
+        hostname = machine_name;
       }
 
       command =  real_exe_name;
@@ -1485,63 +1485,63 @@ SALOME_ContainerManager::BuildCommandToLaunchParallelContainer(const std::string
     {
       std::ifstream * machine_file = NULL;
       if (remote)
-       machine_file = new std::ifstream(machine_file_name.c_str());
+        machine_file = new std::ifstream(machine_file_name.c_str());
       for (int i= 0; i < nb_nodes; i++)
       {
-       std::string command_remote("");
-       if (remote)
-       {
-         std::string machine_name;
-         std::getline(*machine_file, machine_name);
-         MESSAGE("[BuildCommandToLaunchParallelContainer] machine file name extracted is " << machine_name)
-
-           // We want to launch a command like : 
-           // ssh user@machine distantPath/runRemote.sh hostNS portNS
-           const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(machine_name);
-         if (resInfo.Protocol == rsh)
-           command_remote = "rsh ";
-         else 
-           command_remote = "ssh ";
-         command_remote += resInfo.UserName;
-         command_remote += "@";
-         command_remote += machine_name;
-         command_remote += " ";
-         command_remote += resInfo.AppliPath; // path relative to user@machine $HOME
-         command_remote += "/runRemote.sh ";
-         ASSERT(getenv("NSHOST")); 
-         command_remote += getenv("NSHOST"); // hostname of CORBA name server
-         command_remote += " ";
-         ASSERT(getenv("NSPORT"));
-         command_remote += getenv("NSPORT"); // port of CORBA name server
-         command_remote += " ";
-
-         hostname = machine_name;
-       }
-
-       std::ostringstream tmp;
-       tmp << i;
-       std::string proc_number = tmp.str();
-
-       std::string command_tmp("");
-       command_tmp += real_exe_name;
-       command_tmp += " " + _NS->ContainerName(rtn);
-       command_tmp += " " + parallelLib;
-       command_tmp += " " + proxy_hostname;
-       command_tmp += " " + proc_number;
-       command_tmp += " -";
-       AddOmninamesParams(command_tmp);
-
-       // On change _Node_ par _Nodex_ pour avoir chaque noeud
-       // sur un fichier
-       std::string command_end_tmp = command_end;
-       std::string::size_type loc_node = command_end_tmp.find("_Node_");
-       if (loc_node != std::string::npos)
-         command_end_tmp.insert(loc_node+5, proc_number);
-       command += command_begin + command_remote + command_tmp + command_end_tmp;
-       vect_machine.push_back(hostname);
+        std::string command_remote("");
+        if (remote)
+        {
+          std::string machine_name;
+          std::getline(*machine_file, machine_name);
+          MESSAGE("[BuildCommandToLaunchParallelContainer] machine file name extracted is " << machine_name)
+
+            // We want to launch a command like : 
+            // ssh user@machine distantPath/runRemote.sh hostNS portNS
+            const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(machine_name);
+          if (resInfo.Protocol == rsh)
+            command_remote = "rsh ";
+          else 
+            command_remote = "ssh ";
+          command_remote += resInfo.UserName;
+          command_remote += "@";
+          command_remote += machine_name;
+          command_remote += " ";
+          command_remote += resInfo.AppliPath; // path relative to user@machine $HOME
+          command_remote += "/runRemote.sh ";
+          ASSERT(getenv("NSHOST")); 
+          command_remote += getenv("NSHOST"); // hostname of CORBA name server
+          command_remote += " ";
+          ASSERT(getenv("NSPORT"));
+          command_remote += getenv("NSPORT"); // port of CORBA name server
+          command_remote += " ";
+
+          hostname = machine_name;
+        }
+
+        std::ostringstream tmp;
+        tmp << i;
+        std::string proc_number = tmp.str();
+
+        std::string command_tmp("");
+        command_tmp += real_exe_name;
+        command_tmp += " " + _NS->ContainerName(rtn);
+        command_tmp += " " + parallelLib;
+        command_tmp += " " + proxy_hostname;
+        command_tmp += " " + proc_number;
+        command_tmp += " -";
+        AddOmninamesParams(command_tmp);
+
+        // On change _Node_ par _Nodex_ pour avoir chaque noeud
+        // sur un fichier
+        std::string command_end_tmp = command_end;
+        std::string::size_type loc_node = command_end_tmp.find("_Node_");
+        if (loc_node != std::string::npos)
+          command_end_tmp.insert(loc_node+5, proc_number);
+        command += command_begin + command_remote + command_tmp + command_end_tmp;
+        vect_machine.push_back(hostname);
       }
       if (machine_file)
-       delete machine_file;
+        delete machine_file;
     }
   }
   else if (parallelLib == "Mpi")
@@ -1565,9 +1565,9 @@ SALOME_ContainerManager::BuildCommandToLaunchParallelContainer(const std::string
       std::string command_remote("");
       const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(remote_machine);
       if (resInfo.Protocol == rsh)
-       command_remote = "rcp ";
+        command_remote = "rcp ";
       else 
-       command_remote = "scp ";
+        command_remote = "scp ";
 
       command_remote += machine_file_name;
       command_remote += " ";
@@ -1580,8 +1580,8 @@ SALOME_ContainerManager::BuildCommandToLaunchParallelContainer(const std::string
       int status = system(command_remote.c_str());
       if (status == -1)
       {
-       INFOS("copy of the mpi machine file failed !");
-       return "";
+        INFOS("copy of the mpi machine file failed !");
+        return "";
       }
     }
 
@@ -1590,27 +1590,27 @@ SALOME_ContainerManager::BuildCommandToLaunchParallelContainer(const std::string
       std::string command_remote("");
       if (remote)
       {
-       // We want to launch a command like : 
-       // ssh user@machine distantPath/runRemote.sh hostNS portNS
-       const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(remote_machine);
-       if (resInfo.Protocol == rsh)
-         command_remote = "rsh ";
-       else 
-         command_remote = "ssh ";
-       command_remote += resInfo.UserName;
-       command_remote += "@";
-       command_remote += remote_machine;
-       command_remote += " ";
-       command_remote += resInfo.AppliPath; // path relative to user@machine $HOME
-       command_remote += "/runRemote.sh ";
-       ASSERT(getenv("NSHOST")); 
-       command_remote += getenv("NSHOST"); // hostname of CORBA name server
-       command_remote += " ";
-       ASSERT(getenv("NSPORT"));
-       command_remote += getenv("NSPORT"); // port of CORBA name server
-       command_remote += " ";
-
-       hostname = remote_machine;
+        // We want to launch a command like : 
+        // ssh user@machine distantPath/runRemote.sh hostNS portNS
+        const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(remote_machine);
+        if (resInfo.Protocol == rsh)
+          command_remote = "rsh ";
+        else 
+          command_remote = "ssh ";
+        command_remote += resInfo.UserName;
+        command_remote += "@";
+        command_remote += remote_machine;
+        command_remote += " ";
+        command_remote += resInfo.AppliPath; // path relative to user@machine $HOME
+        command_remote += "/runRemote.sh ";
+        ASSERT(getenv("NSHOST")); 
+        command_remote += getenv("NSHOST"); // hostname of CORBA name server
+        command_remote += " ";
+        ASSERT(getenv("NSPORT"));
+        command_remote += getenv("NSPORT"); // port of CORBA name server
+        command_remote += " ";
+
+        hostname = remote_machine;
       }
 
       // We use Dummy proxy for MPI parallel containers
@@ -1631,61 +1631,61 @@ SALOME_ContainerManager::BuildCommandToLaunchParallelContainer(const std::string
       std::string command_remote("");
       if (remote)
       {
-       const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(remote_machine);
-       if (resInfo.Protocol == rsh)
-         command_remote = "rsh ";
-       else 
-         command_remote = "ssh ";
-       command_remote += resInfo.UserName;
-       command_remote += "@";
-       command_remote += remote_machine;
-       command_remote += " ";
-
-       std::string new_real_exe_name("");
-       new_real_exe_name += resInfo.AppliPath; // path relative to user@machine $HOME
-       new_real_exe_name += "/runRemote.sh ";
-       ASSERT(getenv("NSHOST")); 
-       new_real_exe_name += getenv("NSHOST"); // hostname of CORBA name server
-       new_real_exe_name += " ";
-       ASSERT(getenv("NSPORT"));
-       new_real_exe_name += getenv("NSPORT"); // port of CORBA name server
-       new_real_exe_name += " ";
-
-       real_exe_name = new_real_exe_name + real_exe_name;
-       hostname = remote_machine;
+        const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(remote_machine);
+        if (resInfo.Protocol == rsh)
+          command_remote = "rsh ";
+        else 
+          command_remote = "ssh ";
+        command_remote += resInfo.UserName;
+        command_remote += "@";
+        command_remote += remote_machine;
+        command_remote += " ";
+
+        std::string new_real_exe_name("");
+        new_real_exe_name += resInfo.AppliPath; // path relative to user@machine $HOME
+        new_real_exe_name += "/runRemote.sh ";
+        ASSERT(getenv("NSHOST")); 
+        new_real_exe_name += getenv("NSHOST"); // hostname of CORBA name server
+        new_real_exe_name += " ";
+        ASSERT(getenv("NSPORT"));
+        new_real_exe_name += getenv("NSPORT"); // port of CORBA name server
+        new_real_exe_name += " ";
+
+        real_exe_name = new_real_exe_name + real_exe_name;
+        hostname = remote_machine;
       }
 
       const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesList(hostname);
       if (resInfo.mpi == lam)
       {
-       command = "mpiexec -ssi boot ";
-       if (resInfo.Protocol == rsh)
-         command += "rsh ";
-       else 
-         command += "ssh ";
-       command += "-machinefile " + machine_file_name + " "; 
-       command += "-n " + nbproc + " ";
-       command += real_exe_name;
-       command += " " + _NS->ContainerName(rtn);
-       command += " " + parallelLib;
-       command += " " + proxy_hostname;
-       command += " -";
-       AddOmninamesParams(command);
+        command = "mpiexec -ssi boot ";
+        if (resInfo.Protocol == rsh)
+          command += "rsh ";
+        else 
+          command += "ssh ";
+        command += "-machinefile " + machine_file_name + " "; 
+        command += "-n " + nbproc + " ";
+        command += real_exe_name;
+        command += " " + _NS->ContainerName(rtn);
+        command += " " + parallelLib;
+        command += " " + proxy_hostname;
+        command += " -";
+        AddOmninamesParams(command);
       }
       else
       {
-       command = "mpirun -np " + nbproc + " ";
-       command += real_exe_name;
-       command += " " + _NS->ContainerName(rtn);
-       command += " " + parallelLib;
-       command += " " + proxy_hostname;
-       command += " -";
-       AddOmninamesParams(command);
+        command = "mpirun -np " + nbproc + " ";
+        command += real_exe_name;
+        command += " " + _NS->ContainerName(rtn);
+        command += " " + parallelLib;
+        command += " " + proxy_hostname;
+        command += " -";
+        AddOmninamesParams(command);
       }
 
       command = command_begin + command_remote + command + command_end;
       for (int i= 0; i < nb_nodes; i++)
-       vect_machine.push_back(proxy_hostname);
+        vect_machine.push_back(proxy_hostname);
     }
   }
   else
index d5f4b2b2d3f3a6a6b23ec34013e48e563f20637d..e401de3be93db4cd5498ab6c0b3f3d9695a0569d 100644 (file)
@@ -77,14 +77,14 @@ protected:
   void fillBatchLaunchedContainers();
 
   std::string BuildCommandToLaunchRemoteContainer(const std::string& machine,
-                                                 const Engines::MachineParameters& params, 
-                                                 const std::string& container_exe="SALOME_Container");
+                                                  const Engines::MachineParameters& params, 
+                                                  const std::string& container_exe="SALOME_Container");
 
   std::string BuildCommandToLaunchLocalContainer(const Engines::MachineParameters& params, 
                                                  const std::string& container_exe="SALOME_Container");
 
   std::string BuildTempFileToLaunchRemoteContainer(const std::string& machine,
-                                                  const Engines::MachineParameters& params) throw(SALOME_Exception);
+                                                   const Engines::MachineParameters& params) throw(SALOME_Exception);
 
   void RmTmpFile(std::string& tmpFile);
 
@@ -99,14 +99,14 @@ protected:
   // For PacO++ Parallel extension
   typedef std::vector<std::string> actual_launch_machine_t;
   std::string BuildCommandToLaunchParallelContainer(const std::string& exe_name, 
-                                                   const Engines::MachineParameters& params,
-                                                   SALOME_ContainerManager::actual_launch_machine_t & vect_machine, 
-                                                   const std::string proxy_hostname = ""); 
+                                                    const Engines::MachineParameters& params,
+                                                    SALOME_ContainerManager::actual_launch_machine_t & vect_machine, 
+                                                    const std::string proxy_hostname = ""); 
   CORBA::Object_ptr 
   LaunchParallelContainer(const std::string& command, 
-                         const Engines::MachineParameters& params,
-                         const std::string& name,
-                         SALOME_ContainerManager::actual_launch_machine_t & vect_machine);
+                          const Engines::MachineParameters& params,
+                          const std::string& name,
+                          SALOME_ContainerManager::actual_launch_machine_t & vect_machine);
   CORBA::ORB_var _orb;
   PortableServer::POA_var _poa;
 
index 955a1d8d9ba39d3904b7fa1717ab681af1cdd8e1..2e3d893eb2254b589e1ce25e6c8394bcbf140309 100755 (executable)
@@ -42,7 +42,7 @@ from launchConfigureParser import verbose
 
 #=============================================================================
 
-#define an implementation of the container interface
+#define an implementation of the container interface for the container implemented in Python
 
 class SALOME_ContainerPy_i (Engines__POA.Container):
     _orb = None
@@ -58,7 +58,6 @@ class SALOME_ContainerPy_i (Engines__POA.Container):
         self._poa = poa
         myMachine=getShortHostName()
         Container_path = "/Containers/" + myMachine + "/" + containerName
-        #self._containerName = containerName
         self._containerName = Container_path
         if verbose(): print "container name ",self._containerName
 
@@ -174,10 +173,9 @@ class SALOME_ContainerPy_i (Engines__POA.Container):
             if verbose(): print "import ",componentName," successful"
             ret=1
         except:
-            if verbose(): 
-              import traceback
-              traceback.print_exc()
-              print "import ",componentName," not possible"
+            import traceback
+            traceback.print_exc()
+            print "import ",componentName," not possible"
         return ret
 
     #-------------------------------------------------------------------------
@@ -187,24 +185,6 @@ class SALOME_ContainerPy_i (Engines__POA.Container):
         ret = 0
         instanceName = componentName + "_inst_" + `self._numInstance`
         interfaceName = componentName
-        #the_command = "import " + componentName + "\n"
-        #the_command = the_command + "comp_i = " + componentName + "." + componentName
-        #the_command = the_command + "(self._orb, self._poa, self._this(), self._containerName, instanceName, interfaceName)\n"
-        #MESSAGE( "SALOME_ContainerPy_i::load_component_Library :" + str (the_command) )
-        #exec the_command
-        #comp_o = comp_i._this()
-        #if comp_o is not None:
-        #    ret = 1
-        #else:
-            # --- try to import Python component
-        #    retImpl = self.import_component(componentName)
-        #    if retImpl == 1:
-                #import is possible
-        #        ret = 1
-        #    else:
-                #import isn't possible
-        #        ret = 0
-        #return ret
         return self.import_component(componentName)
     
     #-------------------------------------------------------------------------
index 9dae83fb6f4146eb7b878ed3de5c22878ae93e80..e45b939e6fe6eaf1fca397bd523eac46f0535325 100644 (file)
@@ -53,11 +53,11 @@ class CONTAINER_EXPORT Engines_Container_i:
 public:
   Engines_Container_i();
   Engines_Container_i(CORBA::ORB_ptr orb, 
-                     PortableServer::POA_ptr poa,
-                     char * containerName ,
+                      PortableServer::POA_ptr poa,
+                      char * containerName ,
                       int argc, char* argv[],
-                     bool activAndRegist = true,
-                     bool isServantAloneInProcess = true);
+                      bool activAndRegist = true,
+                      bool isServantAloneInProcess = true);
   virtual ~Engines_Container_i();
 
   // --- CORBA methods
@@ -66,15 +66,15 @@ public:
 
   virtual Engines::Component_ptr
   create_component_instance( const char* componentName,
-                            CORBA::Long studyId); // 0 for multiStudy
+                             CORBA::Long studyId); // 0 for multiStudy
 
   Engines::Component_ptr
   find_component_instance( const char* registeredName,
-                          CORBA::Long studyId); // 0 for multiStudy
+                           CORBA::Long studyId); // 0 for multiStudy
 
   Engines::Component_ptr
   load_impl(const char* nameToRegister,
-           const char* componentName);
+            const char* componentName);
 
 
   void remove_impl(Engines::Component_ptr component_i);
@@ -101,12 +101,12 @@ public:
 
   Engines::Component_ptr
   find_or_create_instance( std::string genericRegisterName,
-                          std::string componentLibraryName);
+                           std::string componentLibraryName);
 
   Engines::Component_ptr
   createInstance(std::string genericRegisterName,
-                void *handle,
-                int studyId);
+                 void *handle,
+                 int studyId);
 
   static bool isPythonContainer(const char* ContainerName);
   static void decInstanceCnt(std::string genericRegisterName);
index 62c06dbcb6ff82e31997655664af0e8dba63d530..f4b670be78166871b084576e635b0bc915ef0392 100644 (file)
@@ -48,7 +48,7 @@ fileRef_i::fileRef_i()
 //=============================================================================
 
 fileRef_i::fileRef_i(Engines::Container_ptr container,
-                    const char* origFileName)
+                     const char* origFileName)
 {
   MESSAGE("fileRef_i::fileRef_i "<< origFileName);
   _container =  Engines::Container::_duplicate(container);
@@ -126,7 +126,7 @@ Engines::Container_ptr fileRef_i::getContainer()
 //=============================================================================
 
 CORBA::Boolean fileRef_i::addRef(const char* machine,
-                                const char* fileName)
+                                 const char* fileName)
 {
   MESSAGE("fileRef_i::addRef " << machine << " " << fileName);
   string theMachine = machine;
@@ -147,7 +147,7 @@ CORBA::Boolean fileRef_i::addRef(const char* machine,
   if (! _copies[theMachine].empty())
     {
       INFOS("there is already a copy on " << theMachine << " under the path "
-           <<  _copies[theMachine] << " new ref not added! ");
+            <<  _copies[theMachine] << " new ref not added! ");
       return 0;
     }
 
@@ -173,12 +173,12 @@ char* fileRef_i::getRef(const char* machine)
   if (_copies[theMachine].empty())
     {
       MESSAGE("no copy of " << _machine << _origFileName << " available on "
-             << theMachine);
+              << theMachine);
     }
   else
     {
       MESSAGE("a copy of " << _machine << _origFileName << "is available on "
-             << theMachine << _copies[theMachine]);
+              << theMachine << _copies[theMachine]);
     }
   return CORBA::string_dup(_copies[theMachine].c_str());
 }
index 357473bf67d0466e4a3f6b48bed36c8aed07aa4c..53266d217c1d87656c36993515a11a69810d1ebb 100644 (file)
@@ -42,7 +42,7 @@ class CONTAINER_EXPORT fileRef_i:
 public:
   fileRef_i();
   fileRef_i(Engines::Container_ptr container,
-           const char* origFileName);
+            const char* origFileName);
   virtual ~fileRef_i();
 
   char* origFileName();
@@ -52,7 +52,7 @@ public:
   Engines::Container_ptr getContainer();
 
   CORBA::Boolean addRef(const char* machine,
-                       const char* fileName);
+                        const char* fileName);
 
   char* getRef(const char* machine);
 
index 567fd1dc50f529bd596f9d91b396336bda00e035..25949f9fc875f5229fc72bba0a71a55fde5f7656 100644 (file)
@@ -175,66 +175,66 @@ Salome_file_i::load(const char* hdf5_file) {
 
       if (mode == "all") {
 
-       // Changing path, is now current directory
-       path = getcwd(NULL, _path_max);
+        // Changing path, is now current directory
+        path = getcwd(NULL, _path_max);
   
-       std::string group_name("GROUP");
-       group_name += file_name;
-       hdf_group = new HDFgroup(group_name.c_str(),hdf_file); 
-       hdf_group->OpenOnDisk();
-       hdf_dataset = new HDFdataset("FILE DATASET",hdf_group);
-       hdf_dataset->OpenOnDisk();
-       size = hdf_dataset->GetSize();
-       buffer = new char[size];
+        std::string group_name("GROUP");
+        group_name += file_name;
+        hdf_group = new HDFgroup(group_name.c_str(),hdf_file); 
+        hdf_group->OpenOnDisk();
+        hdf_dataset = new HDFdataset("FILE DATASET",hdf_group);
+        hdf_dataset->OpenOnDisk();
+        size = hdf_dataset->GetSize();
+        buffer = new char[size];
       
-       if ( (fd = ::open(file_name.c_str(),O_RDWR|O_CREAT,00666)) <0) { 
-         SALOME::ExceptionStruct es;
-         es.type = SALOME::INTERNAL_ERROR;
-         std::string text = "open failed";
-         es.text = CORBA::string_dup(text.c_str());
-         throw SALOME::SALOME_Exception(es);
-       };
-       hdf_dataset->ReadFromDisk(buffer);
-       if ( write(fd,buffer,size) <0) { 
-         SALOME::ExceptionStruct es;
-         es.type = SALOME::INTERNAL_ERROR;
-         std::string text = "write failed";
-         es.text = CORBA::string_dup(text.c_str());
-         throw SALOME::SALOME_Exception(es);
-       };
-       // Close the target file
-       ::close(fd);
-
-       Engines::file infos;
-       infos.file_name = CORBA::string_dup(file_name.c_str());
-       infos.path = CORBA::string_dup(path.c_str());
-       infos.type = CORBA::string_dup(type.c_str());
-       infos.source_file_name = CORBA::string_dup(source_file_name.c_str());
-       infos.status = CORBA::string_dup(status.c_str());
-
-       _fileManaged[file_name] = infos;
-
-       // Update Salome_file state
-       _state.number_of_files++;
-       _state.files_ok = true;
+        if ( (fd = ::open(file_name.c_str(),O_RDWR|O_CREAT,00666)) <0) { 
+          SALOME::ExceptionStruct es;
+          es.type = SALOME::INTERNAL_ERROR;
+          std::string text = "open failed";
+          es.text = CORBA::string_dup(text.c_str());
+          throw SALOME::SALOME_Exception(es);
+        };
+        hdf_dataset->ReadFromDisk(buffer);
+        if ( write(fd,buffer,size) <0) { 
+          SALOME::ExceptionStruct es;
+          es.type = SALOME::INTERNAL_ERROR;
+          std::string text = "write failed";
+          es.text = CORBA::string_dup(text.c_str());
+          throw SALOME::SALOME_Exception(es);
+        };
+        // Close the target file
+        ::close(fd);
+
+        Engines::file infos;
+        infos.file_name = CORBA::string_dup(file_name.c_str());
+        infos.path = CORBA::string_dup(path.c_str());
+        infos.type = CORBA::string_dup(type.c_str());
+        infos.source_file_name = CORBA::string_dup(source_file_name.c_str());
+        infos.status = CORBA::string_dup(status.c_str());
+
+        _fileManaged[file_name] = infos;
+
+        // Update Salome_file state
+        _state.number_of_files++;
+        _state.files_ok = true;
       }
       else {
-       Engines::file infos;
-       infos.file_name = CORBA::string_dup(file_name.c_str());
-       infos.path = CORBA::string_dup(path.c_str());
-       infos.type = CORBA::string_dup(type.c_str());
-       infos.source_file_name = CORBA::string_dup(source_file_name.c_str());
-       infos.status = CORBA::string_dup(status.c_str());
-       // Infos for parallel extensions...
-       infos.node = 0;
-       infos.container = Engines::Container::_duplicate(_container);
-
-       _fileManaged[file_name] = infos;
-
-       // Update Salome_file state
-       _state.number_of_files++;
-       if (status != "ok")
-         _state.files_ok = false;
+        Engines::file infos;
+        infos.file_name = CORBA::string_dup(file_name.c_str());
+        infos.path = CORBA::string_dup(path.c_str());
+        infos.type = CORBA::string_dup(type.c_str());
+        infos.source_file_name = CORBA::string_dup(source_file_name.c_str());
+        infos.status = CORBA::string_dup(status.c_str());
+        // Infos for parallel extensions...
+        infos.node = 0;
+        infos.container = Engines::Container::_duplicate(_container);
+
+        _fileManaged[file_name] = infos;
+
+        // Update Salome_file state
+        _state.number_of_files++;
+        if (status != "ok")
+          _state.files_ok = false;
       }
     }
   }
@@ -631,7 +631,7 @@ Salome_file_i::connect(Engines::Salome_file_ptr source_Salome_file)
       _t_fileDistributedSource::iterator it = _fileDistributedSource.find(file_name);
       if (it == _fileDistributedSource.end()) 
       {
-       _fileDistributedSource[file_name] = Engines::Salome_file::_duplicate(source_Salome_file);
+        _fileDistributedSource[file_name] = Engines::Salome_file::_duplicate(source_Salome_file);
       }
     }
   }
@@ -671,7 +671,7 @@ Salome_file_i::connect(Engines::Salome_file_ptr source_Salome_file)
 //=============================================================================
 void
 Salome_file_i::connectDistributedFile(const char * file_name,
-                                     Engines::Salome_file_ptr source_Salome_file) 
+                                      Engines::Salome_file_ptr source_Salome_file) 
 {
   // Test if this file is added
   _t_fileManaged::iterator it = _fileManaged.find(file_name);
@@ -697,7 +697,7 @@ Salome_file_i::connectDistributedFile(const char * file_name,
 //=============================================================================
 void 
 Salome_file_i::setDistributedSourceFile(const char* file_name,
-                                       const char * source_file_name)
+                                        const char * source_file_name)
 {
   std::string fname(file_name);
 
@@ -738,12 +738,12 @@ Salome_file_i::recvFiles() {
     if (std::string(file_infos.type.in()) == "local")
     {
       if (std::string(file_infos.status.in()) == "not_ok")
-       result = checkLocalFile(file_infos.file_name.in());
+        result = checkLocalFile(file_infos.file_name.in());
     }
     else
     {
       if (std::string(file_infos.status.in()) == "not_ok")
-       result = getDistributedFile(file_infos.file_name.in());
+        result = getDistributedFile(file_infos.file_name.in());
     }
     // if the result is false
     // we add this file to files_not_ok
index d92ab4f4cf7b07aae60dfe93399603b5484e746e..d493dc0898412536a1896ba63cd213b38ed5a2dd 100644 (file)
@@ -58,9 +58,9 @@ class CONTAINER_EXPORT Salome_file_i:
     // Configure DistributedFile
     virtual void connect(Engines::Salome_file_ptr source_Salome_file);
     virtual void connectDistributedFile(const char * file_name,
-                                       Engines::Salome_file_ptr source_Salome_file);
+                                        Engines::Salome_file_ptr source_Salome_file);
     virtual void setDistributedSourceFile(const char* file_name,
-                                         const char * source_file_name);
+                                          const char * source_file_name);
 
     // Recv and check files
     virtual void recvFiles();
index b486c65c5f64948ffbefa160bff018e0ff73cc16..b127d2a32a489a5a80fab84f2d138675ef6b3981 100644 (file)
@@ -193,11 +193,11 @@ bool Engines_MPIContainer_i::Lload_component_Library(const char* componentName)
       PyObject *result = PyObject_CallMethod(pyCont,
                                             (char*)"import_component",
                                             (char*)"s",componentName);
-      int ret= PyInt_AsLong(result);
+      std::string ret= PyString_AsString(result);
       SCRUTE(ret);
       Py_RELEASE_NEW_THREAD;
   
-      if (ret) // import possible: Python component
+      if (ret=="") // import possible: Python component
        {
          _library_map[aCompName] = (void *)pyCont; // any non O value OK
          MESSAGE("[" << _numproc << "] import Python: "<<aCompName<<" OK");
index ec268dc0192590ab2e80f30b7f0ec8843358ecca..74d4edfe1efa46ab7527033a51631e60c83d0b36 100644 (file)
@@ -209,11 +209,11 @@ Container_proxy_impl_final::load_component_Library(const char* componentName)
       PyObject *result = PyObject_CallMethod(pyCont,
                                             (char*)"import_component",
                                             (char*)"s",componentName);
-      int ret_p= PyInt_AsLong(result);
+      std::string ret_p= PyString_AsString(result);
       Py_XDECREF(result);
       Py_RELEASE_NEW_THREAD;
 
-      if (ret_p) // import possible: Python component
+      if (ret_p=="") // import possible: Python component
       {
        MESSAGE("import Python: " << aCompName <<" OK");
       }
index 1213347d2aa049811e81375639d9b78ac1d2f7c7..d39f0a799a1baecc7747a21128207cad0ae1ac80 100644 (file)
@@ -349,11 +349,11 @@ Engines_Parallel_Container_i::load_component_Library(const char* componentName)
     PyObject *result = PyObject_CallMethod(pyCont,
                                           (char*)"import_component",
                                           (char*)"s",componentName);
-    int ret_p= PyInt_AsLong(result);
+    std::string ret_p= PyString_AsString(result);
     Py_XDECREF(result);
     Py_RELEASE_NEW_THREAD;
 
-    if (ret_p) // import possible: Python component
+    if (ret_p=="") // import possible: Python component
     {
       _library_map[aCompName] = (void *)pyCont; // any non O value OK
       MESSAGE("import Python: " << aCompName <<" OK");