openlabs/poweremail — Issue #13: Error Downloading Full Mail (Russian)
Author: Naghual
Created: 2011-12-21 16:02:54+00:00
State: open

When pressing 'Download Full Mail' button, error appears:

web-services:Uncaught exception
Traceback (most recent call last):
File "/opt/openerp/lib/python2.7/site-packages/openerp-server/osv/osv.py", line 122, in wrapper
return f(self, dbname, *args, **kwargs)
File "/opt/openerp/lib/python2.7/site-packages/openerp-server/osv/osv.py", line 176, in execute
res = self.execute_cr(cr, uid, obj, method, *args, **kw)
File "/opt/openerp/lib/python2.7/site-packages/openerp-server/osv/osv.py", line 167, in execute_cr
return getattr(object, method)(cr, uid, *args, **kw)
File "/opt/openerp/lib/python2.7/site-packages/openerp-server/addons/openlabs-poweremail-652f768/poweremail_mailbox.py", line 157, in complete_mail
self.pool.get('poweremail.core_accounts').get_fullmail(cr, uid, id, context)
File "/opt/openerp/lib/python2.7/site-packages/openerp-server/addons/openlabs-poweremail-652f768/poweremail_core.py", line 1007, in get_fullmail
server_ref, mailid, context)
File "/opt/openerp/lib/python2.7/site-packages/openerp-server/addons/openlabs-poweremail-652f768/poweremail_core.py", line 734, in complete_mail
self.save_attachments(cr, uid, mail, mailboxref, parsed_mail, coreaccountid, context)
File "/opt/openerp/lib/python2.7/site-packages/openerp-server/addons/openlabs-poweremail-652f768/poweremail_core.py", line 749, in save_attachments
'description':(self.decode_header_text(mail['subject']) or _('No Subject')) + " [Type:" + (each[0] or 'Unknown') + ", Filename:" + (each[1] or 'No Name') + "]",
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 5: ordinal not in range(128)
> /opt/openerp/lib/python2.7/site-packages/openerp-server/addons/openlabs-poweremail-652f768/poweremail_core.py(749)save_attachments()
-> 'description':(self.decode_header_text(mail['subject']) or _('No Subject')) + " [Type:" + (each[0] or 'Unknown') + ", Filename:" + (each[1] or 'No Name') + "]",

some investigation:

(Pdb) l
744	for each in parsed_mail['attachments']:#Get each attachment
745	new_att_vals = {
746	'name':self.decode_header_text(mail['subject']) + '(' + each[0] + ')',
747	'datas':base64.b64encode(each[2] or ''),
748	'datas_fname':each[1],
749 ->	'description':(self.decode_header_text(mail['subject']) or _('No Subject')) + " [Type:" + (each[0] or 'Unknown') + ", Filename:" + (each[1] or 'No Name') + "]",
750	'res_model':'poweremail.mailbox',
751	'res_id':id
752	}
753	att_ids.append(att_obj.create(cr, uid, new_att_vals, context))
754	logger.notifyChannel(_("Power Email"), netsvc.LOG_INFO, _("Downloaded & saved %s attachments Account: %s.") % (len(att_ids), coreaccountid))
(Pdb) self.decode_header_text(mail['subject'])
'Fwd: \xd0\x9e\xd1\x82\xd0\xbf\xd1\x80\xd0\xb0\xd0\xb2\xd0\xba\xd0\xb0: \xd0\xa1\xd0\xbe\xd1\x81\xd1\x82\xd0\xbe\xd1\x8f\xd0\xbd\xd0\xb8\xd0\xb5_\n \xd0\xb3\xd0\xbe\xd1\x82\xd0\xbe\xd0\xb2\xd0\xbd\xd0\xbe\xd1\x81\xd1\x82\xd0\xb8_\xd0\x98\xd0\x93\xd0\x9f_23122011.xls'
(Pdb) mail['subject']
'Fwd: =?UTF-8?B?0J7RgtC/0YDQsNCy0LrQsDog0KHQvtGB0YLQvtGP0L3QuNC1Xw==?=\n =?UTF-8?B?0LPQvtGC0L7QstC90L7RgdGC0Lhf0JjQk9CfXzIzMTIyMDExLnhscw==?='
(Pdb)