Back to index

salome-kernel  6.5.0
TestComponentPy.py
Go to the documentation of this file.
00001 #! /usr/bin/env python
00002 # Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00003 #
00004 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00005 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00006 #
00007 # This library is free software; you can redistribute it and/or
00008 # modify it under the terms of the GNU Lesser General Public
00009 # License as published by the Free Software Foundation; either
00010 # version 2.1 of the License.
00011 #
00012 # This library is distributed in the hope that it will be useful,
00013 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 # Lesser General Public License for more details.
00016 #
00017 # You should have received a copy of the GNU Lesser General Public
00018 # License along with this library; if not, write to the Free Software
00019 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00020 #
00021 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00022 #
00023 
00024 #  SALOME TestContainer : test of container creation and its life cycle
00025 #  File   : TestComponentPy.py
00026 #  Author : Paul RASCLE, EDF
00027 #  Module : SALOME
00028 #  $Header: /home/server/cvs/KERNEL/KERNEL_SRC/src/TestContainer/TestComponentPy.py,v 1.9.30.2.12.1 2012-04-12 14:05:31 vsr Exp $
00029 #
00030 import os
00031 import sys
00032 import string
00033 from omniORB import CORBA
00034 import CosNaming
00035 import Engines
00036 from Utils_Identity import getShortHostName
00037 
00038 
00039 #initialise the ORB
00040 orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
00041 
00042 #obtain a reference to the root naming context
00043 obj = orb.resolve_initial_references("NameService")
00044 rootContext = obj._narrow(CosNaming.NamingContext)
00045 
00046 if rootContext is None:
00047     print "Name Service Reference is invalid"
00048     sys.exit(1)
00049 
00050 #resolve the name /Containers.dir/FactoryServerPy.object
00051 machineName=getShortHostName()
00052 containerName = "FactoryServerPy"
00053 name = [CosNaming.NameComponent("Containers","dir"),
00054         CosNaming.NameComponent(machineName,"dir"),
00055         CosNaming.NameComponent(containerName,"object")]
00056 
00057 try:
00058     obj = rootContext.resolve(name)
00059 except CosNaming.NamingContext.NotFound, ex:
00060     print  containerName , " not found in Naming Service"
00061     sys.exit(1)
00062 
00063 container = obj._narrow(Engines.Container)
00064 print container.getHostName()
00065 comp = container.load_impl("SALOME_TestComponentPy","SALOME_TestComponentPy")
00066 print comp._get_instanceName()
00067 comp.ping()
00068 comptest = comp._narrow(Engines.TestComponent)
00069 if comptest is None:
00070     print "probleme cast"
00071 print comptest.Coucou(1)
00072 
00073