Changeset 96
- Timestamp:
- 07/13/06 08:23:32 (18 years ago)
- Location:
- emailtotracscript/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
emailtotracscript/trunk/debian/changelog
r92 r96 1 email2trac (0.7.4-2) stable; urgency=low 2 3 * New bug fixes for unicode support 4 5 -- root <root@subtrac.sara.nl> Tue, 11 Jul 2006 14:52:58 +0200 6 7 email2trac (0.7.4-1) stable; urgency=low 8 9 * Unicode bug fixes 10 11 -- root <root@subtrac.sara.nl> Tue, 11 Jul 2006 09:24:00 +0200 12 1 13 email2trac (0.7.3-7) stable; urgency=low 2 14 -
emailtotracscript/trunk/email2trac.py.in
r92 r96 88 88 from stat import * 89 89 import mimetypes 90 91 # Fix some errors 92 #import codecs 93 90 import syslog 91 import traceback 92 93 94 # Some global variables 95 # 94 96 trac_default_version = 0.9 97 m = None 98 95 99 96 100 class TicketEmailParser(object): … … 201 205 202 206 if str: 203 str = '%s %s' %(str, temp)207 str = u'%s %s' %(str, temp) 204 208 else: 205 str = temp 206 209 str = u'%s' %temp 210 211 str = str.encode('utf-8') 207 212 return str 208 213 … … 306 311 for name,mail in addrs: 307 312 try: 308 ticket['cc'] = '%s,%s' %(ticket['cc'], mail)313 mail_list = '%s,%s' %(mail_list, mail) 309 314 except: 310 ticket['cc'] = mail 311 312 def save_email_for_debug(self, message): 313 msg_file = '/var/tmp/msg.txt' 315 mail_list = mail 316 317 ticket['cc'] = self.to_unicode(mail_list) 318 319 def save_email_for_debug(self, message, tempfile=False): 320 if tempfile: 321 import tempfile 322 msg_file = tempfile.mktemp('.email2trac') 323 else: 324 msg_file = '/var/tmp/msg.txt' 314 325 print 'TD: saving email to %s' % msg_file 315 326 fx = open(msg_file, 'wb') … … 382 393 383 394 if not msg['Subject']: 384 tkt['summary'] = '(geen subject)'395 tkt['summary'] = u'(geen subject)' 385 396 else: 386 397 tkt['summary'] = self.to_unicode(msg['Subject']) … … 417 428 # field of a ticket 418 429 # 419 tkt['description'] = 'email2trac:%s\r\n{{{\r\n%s\r\n}}}' \430 tkt['description'] = u'email2trac:%s\r\n{{{\r\n%s\r\n}}}' \ 420 431 %(head, body_text) 421 432 … … 433 444 if self.MAILTO: 434 445 mailto = self.html_mailto_link(self.to_unicode(msg['subject']), ticket_id, body_text) 435 tkt['description'] = 'email2trac:%s%s\r\n{{{\r\n%s\r\n}}}' %(head, mailto, body_text)446 tkt['description'] = u'email2trac:%s%s\r\n{{{\r\n%s\r\n}}}' %(head, mailto, body_text) 436 447 comment = '\nadded mailto line\n' 437 448 changed = True … … 455 466 456 467 def parse(self, fp): 468 global m 469 457 470 m = email.message_from_file(fp) 458 471 if not m: … … 485 498 """ 486 499 has_description = 0 487 ubody_text = '\r\n{{{\nNo plain text message\n}}}\r\n'500 ubody_text = u'\r\n{{{\nNo plain text message\n}}}\r\n' 488 501 for part in msg.walk(): 489 502 … … 505 518 charset = part.get_content_charset('iso-8859-15') 506 519 try: 507 temp= unicode(body_text, charset)520 ubody_text = unicode(body_text, charset) 508 521 except (UnicodeError,LookupError): 509 temp = unicode(body_text, 'iso-8859-15') 510 511 ubody_text = temp.encode('utf-8') 522 ubody_text = unicode(body_text, 'iso-8859-15') 512 523 513 524 elif part.get_content_type() == 'text/html': 514 ubody_text = '\r\n(see attachment for HTML mail message)\r\n'525 ubody_text = u'\r\n(see attachment for HTML mail message)\r\n' 515 526 516 527 else: 517 ubody_text = '\r\n(see attachment for message)\r\n'528 ubody_text = u'\r\n(see attachment for message)\r\n' 518 529 519 530 has_description = 1 … … 521 532 522 533 if not has_description: 523 ubody_text = '\r\n(see attachment for message)\r\n'524 525 return ubody_text 534 ubody_text = u'\r\n(see attachment for message)\r\n' 535 536 return ubody_text.encode('utf-8') 526 537 527 538 def notify(self, tkt , new=True, modtime=0): … … 793 804 # 794 805 except Exception, error: 795 import syslog, traceback 806 if m: 807 self.save_email_for_debug(m, True) 796 808 797 809 if ENABLE_SYSLOG:
Note: See TracChangeset
for help on using the changeset viewer.