RE: [Twisted-Python] How to write a simpletelnet client?

Sorry that i answer so late (busssy week).
I could even switch off the echo (your next thread).
Switching off ECHO i realized by sending a commands: unset PS1 (switching off prompt) stty -echo (swiching off echo)
class MyFactory( ClientFactory ): protocol = TelnetProtocol '''all printouts from this class will have F at the beggining - form Factory and they are green - <g>''' def __init__( self ): print "<g>F __init__" self.protos={} self.nextName = None self.t0 = time.time() def buildProtocol( self, addr ): print "<g>F buildProtocol" p = self.protocol( self.nextName ) p.factory = self self.protos[self.nextName] = p self.nextName = None return p def getClient( self, name ): print "<g>F getClient" t0 = time.time() while True: try: return self.protos[name] except KeyError: reactor.run( 0.1 ) print name print self.nextName while name not in self.nextName: reactor.iterate( 0.1 ) if time.time() - self.t0 > CLIENT_CONNECTION_TIMEOUT: raise TimeoutError, "Timeout on connection" def addActive( self, proto ): print "<g>F addActive" self.engine._storeClient( proto )
participants (1)
-
Michał Tyde