[Twisted-Python] Twisted and ipython

Alessandro Dentella sandro at e-den.it
Thu Jan 13 18:43:09 EST 2011


thanks,

short abstact: manhole is very good, thanks. But I'd need to add readline to
make it usable and I'd need tab-completion too. 


On Thu, Jan 13, 2011 at 12:06:10PM +0000, Michael Thompson wrote:
> On 11 January 2011 07:48, Alessandro Dentella <sandro at e-den.it> wrote:
> 
> > So what's the suggested way to play with twisted?
> 
> It depends what you're trying to do. I'd suggest you get some form of
> skeleton program running first. 

I do have already: it uses SerialPort, queries a serial bus and returns info
on a domotic system (switches & co). Apart from my queries it also listen to
whatever the serial bus issues and react changing the internal state of some
objects.

What I'd like to do is to play interactively with these objects (Eg: a
digital module with 8 switches: I want to switch on/off the exits).

> At that point you can interact with the program using twisted manhole.

this is interesting. I found a working example::

   from twisted.internet import reactor
   from twisted.conch import telnet

   def createShellServer( ):

       print 'Creating shell server instance'
       factory = telnet.ShellFactory()
       port = reactor.listenTCP( 2000, factory)
       factory.namespace['x'] = 'hello world'
       factory.username = 'sd'
       factory.password = 'vega'
       print 'Listening on port 2000'
       return port

   if __name__ == "__main__":

       reactor.callWhenRunning( createShellServer )
       reactor.run()

that raises /usr/lib/python2.6/dist-packages/twisted/manhole/telnet.py:8: DeprecationWarning: As of Twisted 2.1, twisted.protocols.telnet is deprecated.  See twisted.conch.telnet for the current, supported API.
  from twisted.protocols import telnet

I couldn't make out a correct syntax using the new API. Can somebody point
me to the correct solution?

Adding readline
----------------

To make this solution viable to me I really need to have readline and
completion. I found a thread hinting of a patch that should implement it but
no real patch to see [1].

I tryied to start an IPythonShell at the prompt but it simply hangs forever.



sandro
*:-)

[1] http://www.mail-archive.com/twisted-web@twistedmatrix.com/msg02241.html

-- 
Sandro Dentella  *:-)
http://www.reteisi.org             Soluzioni libere per le scuole
http://sqlkit.argolinux.org        SQLkit home page - PyGTK/python/sqlalchemy



More information about the Twisted-Python mailing list