[Twisted-Python] struggling with twisted telnet

Andrew Roden andrew.roden at gmail.com
Wed Aug 8 08:54:56 MDT 2007


ok... thanks for the help so far :)

I've managed to get it 'working' by hashing out the __init__ under the
Telnet Protocol class

class TelnetProtocol(recvline.HistoricRecvLine):
#    def __init__(self, user):
#        self.user = user

That will now allow me to connect to the 'server' but it behaves in a
different way to the SSH server in that if I type in one of my commands...
to see the output and return to the prompt, I have to hit enter twice which
then shows me 2 prompts :(

oh for a nice simple example like the one for SSH in the O'Reilly book :(

Andrew

On 8/8/07, Jean-Paul Calderone <exarkun at divmod.com> wrote:
>
> On Wed, 8 Aug 2007 14:27:36 +0100, Andrew Roden <andrew.roden at gmail.com>
> wrote:
> >The answer is no I wasn't running it with twistd as I didn't need to with
> >the ssh one... having now run it with twistd I can see the exceptions it
> >throws but I have absolutely no clue how to go about rectifying them :(
> >>From what I can make out the main issue is with no terminal size being
> set
> >which from the demo_insults.tac looks like it's set in my class that
> deals
> >with connections associating it with insults.TerminalProtocol (eg. class
> >DemoProtocol(insults.TerminalProtocol): ) however, I am dealing with my
> >connections in recvline as I don't want it to react on a per character
> basis
> >but rather a per line basis...
> >
> >*confused of england*
> >
> >Andrew
> >
>
> The first traceback I see is this one:
>
> 2007-08-08 09:46:39-0400 [twisted.internet.protocol.ServerFactory]
> Unhandled Error
>         Traceback (most recent call last):
>           File
> "/home/exarkun/Projects/Twisted/trunk/twisted/python/log.py", line 36, in
> callWithContext
>             return context.call({ILogContext: newCtx}, func, *args, **kw)
>           File
> "/home/exarkun/Projects/Twisted/trunk/twisted/python/context.py", line 59,
> in callWithContext
>             return self.currentContext().callWithContext(ctx, func, *args,
> **kw)
>           File
> "/home/exarkun/Projects/Twisted/trunk/twisted/python/context.py", line 37,
> in callWithContext
>             return func(*args,**kw)
>           File
> "/home/exarkun/Projects/Twisted/trunk/twisted/internet/selectreactor.py",
> line 139, in _doReadOrWrite
>             why = getattr(selectable, method)()
>         --- <exception caught here> ---
>           File
> "/home/exarkun/Projects/Twisted/trunk/twisted/internet/tcp.py", line 813, in
> doRead
>             protocol.makeConnection(transport)
>           File
> "/home/exarkun/Projects/Twisted/trunk/twisted/internet/protocol.py", line
> 333, in makeConnection
>             self.connectionMade()
>           File
> "/home/exarkun/Projects/Twisted/trunk/twisted/conch/telnet.py", line 732, in
> connectionMade
>             self.protocol.makeConnection(self)
>           File
> "/home/exarkun/Projects/Twisted/trunk/twisted/internet/protocol.py", line
> 333, in makeConnection
>             self.connectionMade()
>           File
> "/home/exarkun/Projects/Twisted/trunk/twisted/conch/telnet.py", line 795, in
> connectionMade
>             self.protocol.makeConnection(self)
>           File
> "/home/exarkun/Projects/Twisted/trunk/twisted/internet/protocol.py", line
> 333, in makeConnection
>             self.connectionMade()
>           File
> "/home/exarkun/Projects/Twisted/trunk/twisted/conch/insults/insults.py",
> line 416, in connectionMade
>             self.terminalProtocol = self.protocolFactory (*
> self.protocolArgs, **self.protocolKwArgs)
>         exceptions.TypeError: __init__() takes exactly 2 arguments (1
> given)
>
> Python is really helpful here, omitting the class name which has the bad
> __init__, but I guess you can track that down with a little effort (and
> there are probably only a small number of candidates).
>
> The next one I see is this:
>
> 2007-08-08 09:46:39-0400 [TelnetTransport,0,127.0.0.1] Unhandled Error
>         Traceback (most recent call last):
>           File
> "/home/exarkun/Projects/Twisted/trunk/twisted/python/log.py", line 51, in
> callWithLogger
>             return callWithContext({"system": lp}, func, *args, **kw)
>           File
> "/home/exarkun/Projects/Twisted/trunk/twisted/python/log.py", line 36, in
> callWithContext
>             return context.call({ILogContext: newCtx}, func, *args, **kw)
>           File
> "/home/exarkun/Projects/Twisted/trunk/twisted/python/context.py", line 59,
> in callWithContext
>             return self.currentContext().callWithContext(ctx, func, *args,
> **kw)
>           File
> "/home/exarkun/Projects/Twisted/trunk/twisted/python/context.py", line 37,
> in callWithContext
>             return func(*args,**kw)
>         --- <exception caught here> ---
>           File
> "/home/exarkun/Projects/Twisted/trunk/twisted/internet/selectreactor.py",
> line 139, in _doReadOrWrite
>             why = getattr(selectable, method)()
>           File
> "/home/exarkun/Projects/Twisted/trunk/twisted/internet/tcp.py", line 362, in
> doRead
>             return self.protocol.dataReceived(data)
>           File
> "/home/exarkun/Projects/Twisted/trunk/twisted/conch/telnet.py", line 483, in
> dataReceived
>             self.negotiate(commands)
>           File
> "/home/exarkun/Projects/Twisted/trunk/twisted/conch/telnet.py", line 526, in
> negotiate
>             cmdFunc(bytes)
>           File
> "/home/exarkun/Projects/Twisted/trunk/twisted/conch/telnet.py", line 833, in
> telnet_NAWS
>             self.protocol.terminalProtocol.terminalSize(width, height)
>         exceptions.AttributeError: 'NoneType' object has no attribute
> 'terminalSize'
>
> This may just be a consequence of the first one, so I'd try resolving the
> first one before looking more at this.
>
> Jean-Paul
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20070808/497bc46a/attachment.html>


More information about the Twisted-Python mailing list