UnicodeDecodeError: 'ascii' codec can't decodee byte 0xff in position 0: ordinal not in range(128)

Hoàng Tuấn Việt vietht2 at viettel.com.vn
Sun Nov 17 23:55:39 EST 2013


Hi all,

 

I use Python telnetlib on Windows 7 32 bit. Here is my code:

 


    def telnet(self, host, os, username, password):

        connection = telnetlib.Telnet(host)

        connection.read_until('login: ')

        connection.write(username + '\r')

        connection.read_until('assword: ')

        connection.write(password + '\r')

        connection.read_until('>', timeout = TIMEOUT)

       return connection

 

I can run the program in Eclipse and telnet successfully to a Windows host.

 

But when I export to .exe file:

 


from distutils.core import setup

import py2exe

 

setup(

    options = {

            "py2exe":{

            "packages": ['wx.lib.pubsub'],

            "dll_excludes": ["MSVCP90.dll", "HID.DLL", "w9xpopen.exe"],

        }

    },

    console = [{'script': ‘my_program.py'}]

)

 

and run the programe, I encounter this error:

 


UnicodeDecodeError: 'ascii' codec can't decodee byte 0xff in position 0: ordinal not in range(128)

 

at line:

 


connection.write(username + '\r')

 

I have debugged and searched the Internet hard but found no solution yet.

 

I think it is because of ‘\r’.

 

Do you have any idea?

 

Viet

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20131118/f4508ab4/attachment.html>


More information about the Python-list mailing list