[Twisted-Python] TDDing an ssh client - mocking the server

Justin Warren daedalus at eigenmagic.com
Mon Aug 6 20:12:11 MDT 2007


On Mon, 2007-08-06 at 12:11 +0100, Dave Kirby wrote:
> Firstly a belated thanks to everyone who replied to my previous
> question – I had to put my project on hold for a while, but now I am
> back with more questions.
> 
>  
> 
> My objective is to use twisted to do automated logging in to multiple
> ssh servers to carry out various tasks.  Currently this is done by
> spawning a separate ssh executable for each session and controlling it
> through pexpect, and I would like to replace this with a twisted/conch
> system.

Hi Dave,

The framework I created to do something very similar to this is
available for free at http://modipy.seafelt.com. ModiPY is written using
twisted and currently does pretty much what you've described, spawning a
program in a sub-process to do work. This 'spawn and do work' component
could be replaced by a conch SSH client instead. In fact, this would be
desirable for some things.

> So far I can create conch “exec” sessions to run a single
> command/script and return the result, but I would like to be able to
> create shell sessions and do more interactive work.  Does anyone have
> any examples of doing this?

I'm guessing you want examples of how to use conch to do interactive
work, so ModiPY probably isn't useful here, but you might be able to use
some of the ideas in the ConnectingProvisioner and ExpectProtocol. It
connects to a remote device and runs a series of commands, handling
their output.

-- 
Justin Warren <daedalus at eigenmagic.com>




More information about the Twisted-Python mailing list