File: client.py

package info (click to toggle)
pyro 1%3A3.14-5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,048 kB
  • ctags: 1,988
  • sloc: python: 11,194; xml: 128; sh: 52; makefile: 28
file content (29 lines) | stat: -rw-r--r-- 771 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
#!/usr/bin/env python

import Pyro.naming, Pyro.core
import Pyro.errors

Pyro.core.initClient()
ident = raw_input('Enter authentication ID for NS ("s3cr3t"): ')

locator = Pyro.naming.NameServerLocator(identification=ident)  # note the ID
print 'Searching Naming Service...',
ns = locator.getNS()

print 'Naming Service found at',ns.URI.address,'port',ns.URI.port


print 'binding to object'
try:
    URI=ns.resolve(':test.authentication')
    print 'URI:',URI
except Pyro.core.PyroError,x:
    print 'Couldn\'t bind object, nameserver says:',x
    raise SystemExit

ident = raw_input('Enter authentication ID for Server ("s3cr3t"): ')
obj=Pyro.core.getProxyForURI(URI)
obj._setIdentification(ident)
result=obj.method('foo bar')
print "Result from method call: ",result