Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!eweka.nl!hq-usenetpeers.eweka.nl!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:not': 0.03; 'skip:[ 20': 0.04; 'yet.': 0.04; 'error:': 0.07; "subject:' ": 0.07; 'username,': 0.07; 'host,': 0.09; 'idea?': 0.09; 'line:': 0.09; 'subject:position': 0.09; 'python': 0.11; 'def': 0.12; 'windows': 0.15; 'bit.': 0.16; 'codec': 0.16; 'debugged': 0.16; 'eclipse': 0.16; 'ordinal': 0.16; 'skip:[ 40': 0.16; 'subject: \n ': 0.16; 'timeout': 0.16; 'timeout)': 0.16; 'all,': 0.19; 'import': 0.22; 'byte': 0.24; 'skip:{ 20': 0.24; 'options': 0.25; 'code:': 0.26; "skip:' 10": 0.31; 'file:': 0.31; 'os,': 0.31; 'skip:c 30': 0.32; 'run': 0.32; "can't": 0.35; 'connection': 0.35; 'but': 0.35; 'url:rec-html40': 0.35; 'url:org': 0.36; 'url:microsoft': 0.37; 'url:office': 0.38; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'url:schemas': 0.38; 'url:omml': 0.39; 'url:2004': 0.39; 'skip:& 20': 0.39; 'subject:can': 0.39; 'url:12': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'skip:u 10': 0.60; 'skip:t 30': 0.61; 'from:charset:utf-8': 0.61; 'skip:\xe2 10': 0.65; 'here': 0.66; '8bit%:74': 0.68; '8bit%:96': 0.70; 'internet': 0.71; 'export': 0.74; 'received:203': 0.74; '8bit%:16': 0.84; 'received:220.231': 0.84; '8bit%:58': 0.91; '8bit%:70': 0.91; '8bit%:55': 0.93 Date: Mon, 18 Nov 2013 11:55:39 +0700 From: =?utf-8?B?SG/DoG5nIFR14bqlbiBWaeG7h3Q=?= Subject: UnicodeDecodeError: 'ascii' codec can't decodee byte 0xff in position 0: ordinal not in range(128) Sender: vietht2@viettel.com.vn To: python-list@python.org MIME-version: 1.0 X-Mailer: Microsoft Outlook 14.0 Content-type: multipart/alternative; boundary="Boundary_(ID_E/4IbDwDEnubOe6Ijgqz/A)" Content-language: en-us Thread-index: Ac7kGOU/AnVipb6bTz6AgyazK2Iu2g== X-Mailman-Approved-At: Mon, 18 Nov 2013 09:27:19 +0100 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 346 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1384763240 news.xs4all.nl 15964 [2001:888:2000:d::a6]:38736 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:59840 This is a multipart message in MIME format. --Boundary_(ID_E/4IbDwDEnubOe6Ijgqz/A) Content-type: text/plain; charset=utf-8 Content-transfer-encoding: quoted-printable Hi all, =20 I use Python telnetlib on Windows 7 32 bit. Here is my code: =20 def telnet(self, host, os, username, password): connection =3D telnetlib.Telnet(host) connection.read_until('login: ') connection.write(username + '\r') connection.read_until('assword: ') connection.write(password + '\r') connection.read_until('>', timeout =3D TIMEOUT) return connection =20 I can run the program in Eclipse and telnet successfully to a Windows = host. =20 But when I export to .exe file: =20 from distutils.core import setup import py2exe =20 setup( options =3D { "py2exe":{ "packages": ['wx.lib.pubsub'], "dll_excludes": ["MSVCP90.dll", "HID.DLL", "w9xpopen.exe"], } }, console =3D [{'script': =E2=80=98my_program.py'}] ) =20 and run the programe, I encounter this error: =20 UnicodeDecodeError: 'ascii' codec can't decodee byte 0xff in position 0: = ordinal not in range(128) =20 at line: =20 connection.write(username + '\r') =20 I have debugged and searched the Internet hard but found no solution = yet. =20 I think it is because of =E2=80=98\r=E2=80=99. =20 Do you have any idea? =20 Viet --Boundary_(ID_E/4IbDwDEnubOe6Ijgqz/A) Content-type: text/html; charset=utf-8 Content-transfer-encoding: quoted-printable

Hi = all,

 

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

 

=C2=A0=C2=A0=C2= =A0 def = telnet(self, host, os, username, password):

=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 connection =3D = telnetlib.Telnet(host)

=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 connection.read_until('login: = ')

=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 connection.write(usernam= e + '\r')

=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 connection.read_until('assword: = ')

=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 connection.write(password + '\r'= )

=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 connection.read_until('>', timeout = =3D TIMEOUT)

= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0return<= span style=3D'font-size:10.0pt;font-family:Consolas;color:black'> = 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<= span style=3D'font-size:10.0pt;font-family:Consolas;color:black'> = setup

import<= span style=3D'font-size:10.0pt;font-family:Consolas;color:black'> = py2exe

 <= /p>

setup(=

=C2=A0=C2=A0=C2= =A0 options =3D {

=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "py2ex= e":{

=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "packa= ges": = ['wx.lib.pub= sub'],

=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "dll_e= xcludes": = ["MSVCP= 90.dll", = "HID.D= LL", = "w9xpo= pen.exe"],

=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 }

=C2=A0=C2=A0=C2= =A0 },

=C2=A0=C2=A0=C2= =A0 console =3D [{'script': = =E2=80=98my= _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(usernam= e + '\r')

 

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

 

I think it is because of =E2=80=98\r=E2=80=99.

 

Do you have any idea?

 

Viet

= --Boundary_(ID_E/4IbDwDEnubOe6Ijgqz/A)--