Changeset 48 for emailtotracscript
- Timestamp:
- 02/01/06 08:58:14 (17 years ago)
- Location:
- emailtotracscript/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
emailtotracscript/trunk/ChangeLog
r46 r48 16 16 of the email-address (only for trac version > 0.9) 17 17 Implemented by: Kilian Cavalotti 18 * Fixed an error in saving attachments for version < 0.9. 19 Sometimes we got bogus attachments. 20 Fixed by: Walter de Jong 18 21 19 22 2006-01-21 Bas van der Vlies <basv@sara.nl>: -
emailtotracscript/trunk/email2trac.py.in
r46 r48 490 490 filename = self.to_unicode(filename) 491 491 492 if '/' in filename: 493 filename = os.path.basename(filename) 492 # From the trac code 493 # 494 filename = filename.replace('\\', '/').replace(':', '/') 495 filename = os.path.basename(filename) 496 497 # We try to normalize the filename to utf-8 NFC if we can. 498 # Files uploaded from OS X might be in NFD. 499 # 500 if sys.version_info[0] > 2 or (sys.version_info[0] == 2 and sys.version_info[1] >= 3): 501 filename = unicodedata.normalize('NFC', unicode(filename, 'utf-8')).encode('utf-8') 494 502 495 503 url_filename = urllib.quote(filename) 496 504 497 505 if self.VERSION > 0.8: 498 tmpfile = '/tmp/email2trac-ticket%sattachment' % str(ticket['id']) 506 #tmpfile = '/tmp/email2trac-ticket%sattachment' % str(ticket['id']) 507 dir = '/tmp' 499 508 else: 500 509 dir = os.path.join(self.env.get_attachments_dir(), 'ticket', … … 503 512 mkdir_p(dir, 0755) 504 513 505 tmpfile = os.path.join(dir, url_filename) 506 507 f = open(tmpfile, 'wb') 514 #tmpfile = os.path.join(dir, url_filename) 515 516 path, fd = util.create_unique_file(os.path.join(dir, url_filename)) 517 #f = open(tmpfile, 'wb') 508 518 text = part.get_payload(decode=1) 509 519 if not text: 510 520 text = '(None)' 511 f.write(text) 521 fd.write(text) 522 fd.close() 512 523 513 524 # get the filesize 514 525 # 515 stats = os.lstat(tmpfile) 526 #stats = os.lstat(tmpfile) 527 stats = os.lstat(path) 516 528 filesize = stats[stat.ST_SIZE] 517 529 … … 519 531 # 520 532 if self.VERSION > 0.8: 521 att = attachment.Attachment(self.env,'ticket',ticket['id']) 522 att.insert(url_filename,f,filesize) 523 f.close() 533 fd = open(path) 534 att = attachment.Attachment(self.env,' ticket', ticket['id']) 535 att.insert(url_filename, fd, filesize) 536 fd.close() 524 537 else: 525 538 cursor = self.db.cursor() … … 626 639 from trac.Notify import TicketNotifyEmail 627 640 from trac.web.href import Href 641 from trac import util 628 642 else: 629 643 from trac.Environment import Environment … … 631 645 from trac.Notify import TicketNotifyEmail 632 646 from trac.Href import Href 647 from trac import util 633 648 634 649 env = Environment(settings['project'], create=0)
Note: See TracChangeset
for help on using the changeset viewer.