[Twisted-Python] Re: example stdin handling client that supports readline?
mwh at python.net
Mon May 24 08:13:32 EDT 2004
Christopher Armstrong <radix at twistedmatrix.com> writes:
> Michael Hudson wrote:
>> Andrew Bennetts <andrew-twisted at puzzling.org> writes:
>>>I'm not aware of anyone using readline with Twisted. A couple of options
>>>spring to mind:
>>> - use curses (see doc/examples/cursesclient.py for an example of using
>>> curses in Twisted) to make your own readline-like functionality
>>> - run readline in a thread, and get it to call
>>> reactor.callFromThread(something.gotStdinLine, ...) everytime a user
>>> hits enter.
>>> - just write a GUI interface, and forget readline ;)
>> 4) check out pyrepl from CVS and help me debug the currently rather
>> hackish twisted support :-)
> Heeey, pyrepl is really cool... :-)
It's also scary. I was just saying on IRC:
<mwh> there are bits of code in pyrepl that make me go
<mwh> "i wrote this code? wow. i wonder how it works?"
This is mostly the low-level terminal manipulation stuff.
> radix at radii ~/Projects/pyrepl/pyrepl% python python_reader.py
> ->> import sys; print sys.modules['twisted.internet.reactor']
> <twisted.internet.default.SelectReactor instance at 0x40352e0c>
> # woot, twisted's already being used :-)
> ->> from twisted.internet import reactor
> ->> from twisted.python.util import println
> ->> reactor.callLater(1, println, "\nhi!")
> <twisted.internet.base.DelayedCall instance at 0x40522aac>
> -- output there seems to do some weird stuff with whitespace, but
> anyway, this is pretty cool :-)
Well, yeah, you're writing to the terminal when it's in raw mode.
pyrepl gets upset (cosmetically) when you do that. Tracebacks are
really, really ugly...
I hate leaving Windows95 boxes publically accessible, so shifting
even to NT is a blessing in some ways. At least I can reboot them
remotely in a sane manner, rather than having to send them malformed
packets. -- http://bofhcam.org/journal/journal.html, 20/06/2000
More information about the Twisted-Python