File: client.py

package info (click to toggle)
python-orbit 0.3.1-12
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,492 kB
  • ctags: 801
  • sloc: sh: 9,444; ansic: 5,642; python: 1,141; makefile: 126
file content (40 lines) | stat: -rwxr-xr-x 1,145 bytes parent folder | download | duplicates (2)
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
37
38
39
40
#!/usr/bin/env python

import urllib, os, sys

idlurl = "http://orbit-python.sault.org/demo/demo.idl"
iorurl = "http://orbit-python.sault.org/demo/demo.ior"

# Fetch the IDL from the server.  We need to do this before we import
# CORBA, because importing CORBA will implicitly preprocess this IDL.
idl = urllib.urlopen(idlurl).read()
open("demo.idl", "w").write(idl)

import CORBA
from _GlobalIDL import Demo

orb = CORBA.ORB_init()
# Fetch the IOR from the server
ior = urllib.urlopen(iorurl).readline()
o = orb.string_to_object(ior)
try:
	version = o.demo_version
	print "Server is version", version
except CORBA.COMM_FAILURE:
	print "The remote server appears to be down.  Try later?"
	sys.exit(1)

print "Message of the day:", o.motd()

print "The server provides these methods:"
# Filter out attribute accessors (prefixed with _)
methods = filter(lambda x: x[0] != '_', dir(o.__class__))
for method in methods:
	print "   %s: %s" % (method, o.doc(method))

print "\nNow invoking available methods:"
for method in methods:
	if method != "doc" and method != "motd":
		print "%s: %s" % (method, eval("o.%s()" % method))

os.unlink("demo.idl")