Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #59840 > unrolled thread

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

Started byHoàng Tuấn Việt <vietht2@viettel.com.vn>
First post2013-11-18 11:55 +0700
Last post2013-11-18 08:16 -0500
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  UnicodeDecodeError: 'ascii' codec can't decodee byte 0xff in position 0: ordinal not in range(128) Hoàng Tuấn Việt <vietht2@viettel.com.vn> - 2013-11-18 11:55 +0700
    Re: UnicodeDecodeError: 'ascii' codec can't decodee byte 0xff in position  0: ordinal not in range(128) "Colin J. Williams" <cjw@ncf.ca> - 2013-11-18 08:16 -0500

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

FromHoàng Tuấn Việt <vietht2@viettel.com.vn>
Date2013-11-18 11:55 +0700
SubjectUnicodeDecodeError: 'ascii' codec can't decodee byte 0xff in position 0: ordinal not in range(128)
Message-ID<mailman.2825.1384763240.18130.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

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

[toc] | [next] | [standalone]


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

From"Colin J. Williams" <cjw@ncf.ca>
Date2013-11-18 08:16 -0500
SubjectRe: UnicodeDecodeError: 'ascii' codec can't decodee byte 0xff in position 0: ordinal not in range(128)
Message-ID<l6d3vf$2qc$1@theodyn.ncf.ca>
In reply to#59840
On 17/11/2013 11:55 PM, Hoàng Tuấn Việt wrote:
> 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)
>
> returnconnection
>
> I can run the program in Eclipse and telnet successfully to a Windows host.
>
> But when I export to .exe file:
>
> fromdistutils.core importsetup
>
> importpy2exe
>
> 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
>
What about:
    connection.write(username, ' r') ?

Colin W.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web