2 # Copyright (C) 2006-2021 CEA/DEN, EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 # Import the CORBA module
24 from omniORB import CORBA
30 orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
32 # Obtain a reference to the root naming context
33 obj = orb.resolve_initial_references("NameService")
34 rootContext = obj._narrow(CosNaming.NamingContext)
36 if rootContext is None:
37 print("Failed to narrow the root naming context")
40 # Resolve the name "test.my_context/Echo.Object"
41 name = [CosNaming.NameComponent("test", "my_context"),
42 CosNaming.NameComponent("Echo", "Object")]
45 obj = rootContext.resolve(name)
47 except CosNaming.NamingContext.NotFound as ex:
48 print("Name not found")
51 # Narrow the object to an eo::Echo
52 echo = obj._narrow(eo.Echo)
55 print("Object reference is not an eo::Echo")
58 # Invoke the echoString operation
59 message = "Hello from Python"
60 result = echo.echoString(message)
62 print("I said '%s'. The object said '%s'." % (message,result))
79 s1=eo.S1(x=1,y=2,s="aa",b=True,vd=[1,2])
85 s3=eo.S3(x=1,y=2,s="aa",b=True,ob=None)
86 r=echo.echoStruct2(s3)
94 s3=eo.S3(x=1,y=2,s="aa",b=True,ob=ob)
95 r=echo.echoStruct2(s3)
98 s3=eo.S3(x=1,y=2,s="aa",b=True,ob=oc)
99 r=echo.echoStruct2(s3)
102 r=echo.echoObjectVec([ob,ob])
105 r=echo.echoObjectVec([oc,oc])
108 r=echo.echoObjectVec([ob,oc])