[Twisted-Python] Conch Testing server and client

Anshul Singhle anshul.singhle at gmail.com
Fri Jul 1 08:59:12 EDT 2011


I understand that. The problem I'm facing is that unless I write
"reactor.run()" my client isn't starting up. From what I understood in the
trial documentation, I should simply call the connectTCP method and then
return a deferred. However, if I do that, the client isn't starting. I'll
post some of the client code for you info :
class SimpleTransport(transport.SSHClientTransport):
    def verifyHostKey(self, hostKey, fingerprint):
        print 'host key fingerprint: %s' % fingerprint
        return defer.succeed(1)

    def connectionSecure(self):
        self.requestService(
            SimpleUserAuth('webchick',
                SimpleConnection()))

class SimpleUserAuth(userauth.SSHUserAuthClient):
    def getPassword(self):
        return defer.succeed("Thai1mil3ahb")
    def getPublicKey(self):
        print "trying public key"
        path = os.path.expanduser('~/.ssh/id_rsa')
        # this works with rsa too
        # just change the name here and in getPrivateKey
        if not os.path.exists(path) or self.lastPublicKey:
            # the file doesn't exist, or we've tried a public key
            return
        return
keys.Key.fromFile(filename=path+'.pub',passphrase='pikachu').blob()

    def getPrivateKey(self):
        path = os.path.expanduser('~/.ssh/id_rsa')
        return
defer.succeed(keys.Key.fromFile(path,passphrase='pikachu').keyObject)
Now , in my test case :
def test_1(self):
         def got_data(data):
             self.assertEquals(data,"a")
         d = protocol.ClientCreator(reactor,
SimpleTransport).connectTCP('localhost', self.server.getHost().port)
         d.addCallback(got_data)
         return d
The callback is firing, but the client is not started and *data* is a
SimpleTransport Instance.
Any thoughts on why this is happening and what I am doing wrong?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20110701/6f06970b/attachment.htm 


More information about the Twisted-Python mailing list