Salome HOME
Moved some functionality to VTKViewer_Utilities.h
[modules/kernel.git] / src / NamingService / SALOME_NamingServicePy.py
index db2d7563314cce3fbed3d706f1c853dd3c7613c8..2bc3c553ca4cfa4c7969215bbf70fab90c6c338f 100644 (file)
@@ -29,6 +29,7 @@
 #  $Header$
 
 import sys
+import time
 from omniORB import CORBA
 import CosNaming
 from string import *
@@ -45,18 +46,31 @@ class SALOME_NamingServicePy_i:
     #-------------------------------------------------------------------------
 
     def __init__(self, orb):
-        MESSAGE ( "SALOME_NamingServicePy_i::__init__" )
+        #MESSAGE ( "SALOME_NamingServicePy_i::__init__" )
         self._orb = orb
         # initialize root context and current context
-        obj =self._orb.resolve_initial_references("NameService")
-        self._root_context =obj._narrow(CosNaming.NamingContext)
-        self._current_context = self._root_context
+       ok = 0
+       steps = 40
+       while steps > 0 and ok == 0:
+         try:
+            obj =self._orb.resolve_initial_references("NameService")
+            self._root_context =obj._narrow(CosNaming.NamingContext)
+            self._current_context = self._root_context
 
         
-        if self._root_context is None :
-            MESSAGE ( "Name Service Reference is invalid" )
-            sys.exit(1)
+            if self._root_context is None :
+              #MESSAGE ( "Name Service Reference is invalid" )
+              #sys.exit(1)
+             MESSAGE(" Name service not found")
+           else:
+             ok = 1
+         except CORBA.COMM_FAILURE, ex:
+           MESSAGE(" Name service not found")
+         time.sleep(0.25)
+         steps = steps - 1
+        if steps == 0: 
+          MESSAGE ( "Name Service Reference is invalid" )
+          sys.exit(1)
     #-------------------------------------------------------------------------
     def Register(self,ObjRef, Path):
         MESSAGE ( "SALOME_NamingServicePy_i::Register" )
@@ -124,7 +138,7 @@ class SALOME_NamingServicePy_i:
             
     #-------------------------------------------------------------------------
     def Resolve(self, Path):
-        MESSAGE ( "SALOME_NamingServicePy_i::Resolve" )
+        #MESSAGE ( "SALOME_NamingServicePy_i::Resolve" )
         path_list = list(Path)
         if path_list[0]=='/':
             self._current_context = self._root_context