Prev: deduping
Next: __slot__: what is it good for?
From: Thomas Lehmann on 21 Jun 2010 09:04 Hi all, I have written a small python xmlrpc server which checks logfiles of a build sending notifications to the responsible teams. On a machine I'm forced to a problem with one logfile with special characters inside generated by a gnu compiler. Using cheetah for generating the HTML mail I get a: ('ascii' codec can't decode byte 0xe2 in position 25868: ordinal not in range(128)) I have found characters like this: error: expected type-specifier before â<80><98>Assocâ<80><99> (copy and paste of a linux console) I have tried different mechanism but very probably I do not understand how the decode/encode functionality is working. Can somebody help me to get out of that problem? Thanks in advance Thomas
From: John Bokma on 21 Jun 2010 10:53 Thomas Lehmann <t.lehmann(a)rtsgroup.net> writes: > Hi all, > > I have written a small python xmlrpc server which checks logfiles of a > build > sending notifications to the responsible teams. On a machine I'm > forced to > a problem with one logfile with special characters inside generated by > a > gnu compiler. > > Using cheetah for generating the HTML mail I get a: > ('ascii' codec can't decode byte 0xe2 in position 25868: ordinal not > in range(128)) Your email(s) get send as 7 bit (ASCII). Email them as utf-8 and I guess your problem is solved. How do you email the notifications? -- John Bokma j3b Hacking & Hiking in Mexico - http://johnbokma.com/ http://castleamber.com/ - Perl & Python Development
From: Thomas Lehmann on 21 Jun 2010 12:03 > Your email(s) get send as 7 bit (ASCII). Email them as utf-8 and I guess > your problem is solved. > > How do you email the notifications? > I was copying partly the logic from http://code.activestate.com/recipes/473810 Changing to buffer.decode("utf-8", 'replace') where I'm reading the file and changing the html template at top to utf-8 leads to following output: File "/srv/buildManager/BuildManagerMail.py", line 27, in sendMail msgText = MIMEText(htmlMessage, 'html') File "/usr/lib64/python2.6/email/mime/text.py", line 30, in __init__ self.set_payload(_text, _charset) File "/usr/lib64/python2.6/email/message.py", line 224, in set_payload self.set_charset(charset) File "/usr/lib64/python2.6/email/message.py", line 264, in set_charset cte(self) File "/usr/lib64/python2.6/email/encoders.py", line 73, in encode_7or8bit orig.encode('ascii') AttributeError: 'DynamicallyCompiledCheetahTemplate' object has no attribute 'encode'
From: John Bokma on 21 Jun 2010 14:19 Thomas Lehmann <t.lehmann(a)rtsgroup.net> writes: >> Your email(s) get send as 7 bit (ASCII). Email them as utf-8 and I guess >> your problem is solved. >> >> How do you email the notifications? >> > > I was copying partly the logic from http://code.activestate.com/recipes/473810 > Changing to buffer.decode("utf-8", 'replace') where I'm reading the > file and > changing the html template at top to utf-8 leads to following output: Most likely you have to do something like this msgText = MIMEText('your HTML utf-8 message') msg.set_charset('utf-8') msgAlternative.attach(msgText) Or: msgText = MIMEText('your HTML utf-8 message', 'utf-8') [1] msgAlternative.attach(msgText) [1] with a quick Google I found one message stating that this didn't work for utf-8, in Python 3.1.1, see: http://mail.python.org/pipermail/python-list/2010-March/1238611.html -- John Bokma j3b Hacking & Hiking in Mexico - http://johnbokma.com/ http://castleamber.com/ - Perl & Python Development
|
Pages: 1 Prev: deduping Next: __slot__: what is it good for? |