#! /usr/bin/env python
-
-#=============================================================================
-# File : SALOME_NamingServicePy.py
-# Created : lun oct 15 14:55 CEST 2001
-# Author : Estelle Deville, CEA
-# Project : SALOME
-# Copyright : CEA 2001
-# $Header$
-#=============================================================================
+#
+# SALOME NamingService : wrapping NamingService services
+#
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : SALOME_NamingServicePy.py
+# Author : Estelle Deville, CEA
+# Module : SALOME
+# $Header$
import sys
+import time
from omniORB import CORBA
import CosNaming
from string import *
#-------------------------------------------------------------------------
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" )
#-------------------------------------------------------------------------
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