File: echo_clt.py

package info (click to toggle)
python-omniorb 3.6-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch, wheezy
  • size: 3,128 kB
  • ctags: 3,321
  • sloc: cpp: 13,969; python: 8,883; sh: 2,576; xml: 107; makefile: 95; ansic: 35
file content (36 lines) | stat: -rwxr-xr-x 785 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python

import sys

# Import the CORBA module
from omniORB import CORBA

# Import the stubs for the global module
import _GlobalIDL

# Initialise the ORB
orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)

# Get the IOR of an Echo object from the command line (without
# checking that the arguments are sensible!)
ior = sys.argv[1]

# Convert the IOR to an object reference
obj = orb.string_to_object(ior)

# Narrow reference to an Echo object
eo  = obj._narrow(_GlobalIDL.Echo)

if eo is None:
    print "Object reference is not an Echo"
    sys.exit(1)

# Invoke the echoString operation
if len(sys.argv) == 3:
    message = sys.argv[2]
else:
    message = "Hello from Python"

result  = eo.echoString(message)

print "I said '%s'. The object said '%s'." % (message,result)