[Twisted-Python] Interactive Twisted client (newbie question?)
abe at fettig.net
Wed Jan 5 13:48:37 EST 2005
Anthony Tarlano wrote:
> From what I can tell from
> your post is you *really* want is a twisted styx client that sends
> T-messages to a styx server to serve its namespace with R-messages,
> and *you* want to interact with the client synchronously.. You also
> asked for a better way to implement the client not using callbacks,
> but that was not the real issue. For _you_ the real issue is
> synchronously communicating _with_the_styx_client from a command
> If this assumption is correct then all you have to do is make the styx
> client a server as well, for let's say the telnet protocol. Then you
> can use a telnet client to connect to the telnet server (which is also
> the styx client) and bingo issue commands to the styx server (via the
> styx client that is also the telnet server)... Of course you will have
> to pass the styx server messages back to the telnet client
As JP mentioned, you can also use twisted.internet.stdio to provide a
command line interface to your running Twisted application. I'm
attaching a simple app that illustrates the point. Here's an example
$ python stdiodemo.py
Web checker console. Type 'help' for help.
Valid commands: check help quit
check <url>: Attempt to download the given web page
Success: got 26072 bytes.
Failure: 404 Not Found
Failure: DNS lookup failed: address 'not.a.real.site' not found.
stdiodemo.py takes commands from standard input while the reactor is
running. When you type "check <url>", it kicks off an asyncronous task
(downloading the web page), and prints the result when it is finished.
Anthony's suggestion of using a Telnet server could work here too -
there are only a couple minor changes you'd need to make to run this as
a telnet server.
Is that helpful?
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
More information about the Twisted-Python