What am i doing wrong

Alex Martelli aleax at aleax.it
Fri Jul 26 12:13:45 EDT 2002


Lee wrote:
        ...
> def detail() :
>     telnet = telnetlib.Telnet(HOST)
>     telnet.read_until("login: ")

So this tries to telnet to the host named in global variable HOST.  Let's 
see what's in that variable, set a bit later...:

> HOST = entry_ph.grid(row=2, column=1)

Method grid always returns None, therefore HOST is always None.

> Exception in Tkinter callback
> Traceback (most recent call last):
>   File "C:\Python22\lib\lib-tk\Tkinter.py", line 1292, in __call__
>     return apply(self.func, args)
>   File "C:\python scripts\teltest.py", line 9, in detail
>     telnet.read_until("login: ")
>   File "C:\Python22\lib\telnetlib.py", line 294, in read_until
>     while not self.eof and apply(select.select, s_args) == s_reply:
>   File "C:\Python22\lib\telnetlib.py", line 260, in fileno
>     return self.sock.fileno()
> AttributeError: 'NoneType' object has no attribute 'fileno'
> Process terminated with exit code 0

and from this trace, we know that self.sock is also None (the
only object of type NoneType).  Unsurprising.


The point is that you don't really want to telnet to host None,
but rather to a hostname that is the content of an entry field
when 'detail' starts running.  Therefore, have function detail
start by getting that field's text content, and use that as the
argument to telnetlib.Telnet, and so on.


Alex




More information about the Python-list mailing list