#! /usr/bin/python # -*- Mode: Python -*- # vi:si:et:sw=4:sts=4:ts=4 from twisted.spread import pb from twisted.internet import reactor from twisted.cred import credentials def main(): factory = pb.PBClientFactory() reactor.connectTCP("localhost", 8900, factory) def1 = factory.login(credentials.UsernamePassword("admin", "pass")) def1.addCallback(connected) reactor.run() def connected(perspective): print "got perspective ref:", perspective print "asking it if it can succeed" cb = perspective.callRemote("succeed") cb.addCallback(fail, perspective) def fail(somearg, perspective): print "now ask it if it can fail" cb = perspective.callRemote("fail") cb.addErrback(errback) def errback(Failure): print "whaddayaknow, it failed" print Failure main()