#! /usr/bin/env python
-# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
#
# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
+
# SALOME NamingService : wrapping NamingService services
# File : SALOME_NamingServicePy.py
# Author : Estelle Deville, CEA
# Module : SALOME
# $Header$
+## @package SALOME_NamingServicePy
+# \brief Module to manage SALOME naming service from python
#
import sys
import time
#=============================================================================
class SALOME_NamingServicePy_i(object):
+ """
+ A class to manage SALOME naming service from python code
+ """
_orb = None
_root_context=None
_current_context=None
#-------------------------------------------------------------------------
- def __init__(self, orb):
+ def __init__(self, orb=None):
+ """
+ Standard Constructor, with ORB reference.
+
+ Initializes the naming service root context
+ """
#MESSAGE ( "SALOME_NamingServicePy_i::__init__" )
+ if orb is None:
+ orb=CORBA.ORB_init([''], CORBA.ORB_ID)
self._orb = orb
# initialize root context and current context
- ok = 0
- steps = 240
- while steps > 0 and ok == 0:
- try:
+ ok = 0
+ steps = 240
+ 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)
- MESSAGE(" Name service not found")
- else:
- ok = 1
- except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE):
- MESSAGE(" Name service not found")
- time.sleep(0.25)
- steps = steps - 1
+ MESSAGE(" Name service not found")
+ else:
+ ok = 1
+ except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE):
+ MESSAGE(" Name service not found")
+ time.sleep(0.25)
+ steps = steps - 1
if steps == 0 and self._root_context is None:
MESSAGE ( "Name Service Reference is invalid" )
sys.exit(1)
#-------------------------------------------------------------------------
def Create_Directory(self,ObjRef, Path):
+ """ ns.Create_Directory(ObjRef, Path)
+
+ create a sub directory
+ """
MESSAGE ( "SALOME_NamingServicePy_i::Create_Directory" )
_not_exist = 0
path_list = list(Path)
MESSAGE ( "Create_Directory : CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE" )
def Destroy_Name(self,Path):
+ """ ns.Destroy_Name(Path)
+
+ remove a name in naming service
+ """
resolve_path=string.split(Path,'/')
if resolve_path[0] == '': del resolve_path[0]
dir_path=resolve_path[:-1]
return
def Destroy_FullDirectory(self,Path):
+ """ ns.Destroy_FullDirectory(Path)
+
+ remove recursively a directory
+ """
context_name=[]
for e in string.split(Path,'/'):
if e == '':continue