[Twisted-Python] Insults, Can't write from connectionMade?
Jean-Paul Calderone
exarkun at divmod.com
Sat Jul 8 10:31:55 MDT 2006
On Sat, 8 Jul 2006 11:55:55 -0400, Mike Pelletier <mike at mkp.ca> wrote:
>Hello, twisted Twisted coders. I am trying to get familiarised with
>twisted.conch.insults. I've run into some behaviour I cannot explain.
>Attached is a .tac including the following excerpt:
>
>class MyTerminalProtocol(insults.TerminalProtocol):
> width = 80
> height = 24
>
> def connectionMade(self):
> self.terminalSize(self.width, self.height)
> self.terminal.write(" world\n")
>
> def terminalSize(self, width, height):
> self.width, self.height = width, height
> self.terminal.eraseDisplay()
> self.terminal.write("Hello,")
>
>When a connection is made, the screen is cleared and "Hello," is written,
>but " world\n" is not (or at least it never appears on the terminal). Why
>is "world\n" not written?
It actually is written:
>>> import socket
>>> s = socket.socket()
>>> s.connect(('localhost', 1977))
>>> s.recv(1024)
'\xff\xfd"\xff\xfd\x1f\xff\xfd\x03\xff\xfb\x01\x1b[2JHello, world\r\r\r\n'
I'm not sure why "Hello," shows up in an xterm but " world" doesn't: it
may be a terminal emulation bug or some legitimate interaction between
all the control sequences included there. But clearly there is a problem
here somewhere - your \n is being translated into \r\r\r\n.
Could you file a ticket in the tracker and attach this tac file?
>
>Oddly (or perhaps revealingly for someone with more clues than me), when in a
>previous version I did not use TelnetTransport and TelnetBootstrapProtocol, I
>was able to write just fine from connectionMade.
>
>TIA for a liberal and violent application of the clue stick.
>
Jean-Paul
More information about the Twisted-Python
mailing list