~certify-web-dev/twisted/certify-trunk

« back to all changes in this revision

Viewing changes to doc/examples/pbechoclient.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2006-01-16 19:56:10 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060116195610-ykmxbia4mnnod9o2
Tags: 2.1.0-0ubuntu2
debian/copyright: Include copyright for python 2.3; some 2.3 files
are included in the upstream tarball, but not in the binary packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
# Copyright (c) 2001-2004 Twisted Matrix Laboratories.
 
3
# See LICENSE for details.
 
4
 
 
5
 
 
6
from twisted.internet import reactor
 
7
from twisted.spread import pb
 
8
from twisted.cred.credentials import UsernamePassword
 
9
 
 
10
from pbecho import DefinedError
 
11
 
 
12
def success(message):
 
13
    print "Message received:",message
 
14
    # reactor.stop()
 
15
 
 
16
def failure(error):
 
17
    t = error.trap(DefinedError)
 
18
    print "error received:", t
 
19
    reactor.stop()
 
20
 
 
21
def connected(perspective):
 
22
    perspective.callRemote('echo', "hello world").addCallbacks(success, failure)
 
23
    perspective.callRemote('error').addCallbacks(success, failure)
 
24
    print "connected."
 
25
 
 
26
 
 
27
factory = pb.PBClientFactory()
 
28
reactor.connectTCP("localhost", pb.portno, factory)
 
29
factory.login(
 
30
    UsernamePassword("guest", "guest")).addCallbacks(connected, failure)
 
31
 
 
32
reactor.run()