[Twisted-Python] Manhole and StandardIO
Zoran Bosnjak
Zoran.Bosnjak at sloveniacontrol.si
Tue Jan 13 02:08:06 MST 2009
> StandardIO accepts an IProtocol provider as an argument.
> Manhole does not implement IProtocol, it implements
> ITerminalProtocol. So you cannot use these two classes
> together like this.
>
> See twisted/conch/stdio.py for examples of how to use manhole
> on stdio.
Thanks for your suggestion. It works well.
But the screen is cleared before prompt is displayed. Can I prevent this?
Here is my script:
---
import os, tty, sys, termios
from twisted.internet import reactor, stdio
from twisted.conch.insults.insults import ServerProtocol
from twisted.conch.manhole import Manhole
class ConsoleManhole(Manhole):
def connectionLost(self, reason):
reactor.stop()
fd = sys.__stdin__.fileno()
oldSettings = termios.tcgetattr(fd)
tty.setraw(fd)
try:
p = ServerProtocol(ConsoleManhole)
stdio.StandardIO(p)
reactor.run()
finally:
termios.tcsetattr(fd, termios.TCSANOW, oldSettings)
os.write(fd, "\r\x1bc\r")
---
Zoran
More information about the Twisted-Python
mailing list