Changeset 172
- Timestamp:
- 07/07/07 12:46:09 (16 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r171 r172 21 21 Implemented by: basv@sara.nl 22 22 23 * Dropped support for version trac version 0.8. Removed all 0.8 24 specific code. 25 Fixed by: basv@sara.nl 23 26 24 27 2007-04-27 -
trunk/email2trac.py.in
r169 r172 58 58 mailto_cc : basv@sara.nl # OPTIONAL, use this address as CC in mailto line 59 59 ticket_update: 1 # OPTIONAL, if set then check if this is an update for a ticket 60 trac_version : 0. 8# OPTIONAL, default is 0.1060 trac_version : 0.9 # OPTIONAL, default is 0.10 61 61 62 62 [jouvin] # OPTIONAL project declaration, if set both fields necessary … … 117 117 118 118 self.VERSION = version 119 if self.VERSION == 0.8: 120 self.get_config = self.env.get_config 121 else: 122 self.get_config = self.env.config.get 119 self.get_config = self.env.config.get 123 120 124 121 if parameters.has_key('umask'): … … 317 314 # Look for email address in registered trac users 318 315 # 319 if self.VERSION == 0.8: 320 users = [] 321 else: 322 users = [ u for (u, n, e) in self.env.get_known_users(self.db) 316 users = [ u for (u, n, e) in self.env.get_known_users(self.db) 323 317 if e == self.email_addr ] 324 318 … … 470 464 return False 471 465 472 body_text = self.get_body_text(m)473 474 466 # Must we update ticket fields 475 467 # … … 494 486 when = int(time.time()) 495 487 496 if self.VERSION == 0.8: 497 tkt = Ticket(self.db, ticket_id) 498 tkt.save_changes(self.db, self.author, body_text, when) 499 else: 500 try: 501 tkt = Ticket(self.env, ticket_id, self.db) 502 except util.TracError, detail: 503 return False 504 505 # Must we update some ticket fields properties 506 # 488 try: 489 tkt = Ticket(self.env, ticket_id, self.db) 490 except util.TracError, detail: 491 return False 492 493 # Must we update some ticket fields properties 494 # 495 if update_tkt_fields: 507 496 self.update_ticket_fields(tkt, update_tkt_fields) 508 497 509 tkt.save_changes(self.author, body_text, when) 510 tkt['id'] = ticket_id 498 body_text = self.get_body_text(m) 499 500 tkt.save_changes(self.author, body_text, when) 501 tkt['id'] = ticket_id 511 502 512 503 if self.VERSION == 0.9: … … 569 560 570 561 when = int(time.time()) 571 if self.VERSION == 0.8: 572 ticket_id = tkt.insert(self.db) 573 else: 574 ticket_id = tkt.insert() 575 tkt['id'] = ticket_id 562 563 ticket_id = tkt.insert() 564 tkt['id'] = ticket_id 576 565 577 566 changed = False … … 593 582 594 583 if changed: 595 if self.VERSION == 0.8: 596 tkt.save_changes(self.db, self.author, comment) 597 else: 598 tkt.save_changes(self.author, comment) 599 600 #print tkt.get_changelog(self.db, when) 584 tkt.save_changes(self.author, comment) 585 #print tkt.get_changelog(self.db, when) 601 586 602 587 if self.notification: … … 848 833 849 834 url_filename = urllib.quote(filename) 850 if self.VERSION == 0.8: 851 dir = os.path.join(self.env.get_attachments_dir(), 'ticket', 852 urllib.quote(str(ticket['id']))) 853 if not os.path.exists(dir): 854 mkdir_p(dir, 0755) 855 else: 856 dir = '/tmp' 857 835 # 836 # Must be tuneables HvB 837 # 838 dir = '/tmp' 858 839 path, fd = util.create_unique_file(os.path.join(dir, url_filename)) 859 840 text = part.get_payload(decode=1) … … 879 860 count = count + 1 880 861 881 # Insert the attachment it differs for the different TRAC versions862 # Insert the attachment 882 863 # 883 if self.VERSION == 0.8: 884 cursor = self.db.cursor() 885 try: 886 cursor.execute('INSERT INTO attachment VALUES("%s","%s","%s",%d,%d,"%s","%s","%s")' 887 %('ticket', urllib.quote(str(ticket['id'])), filename + '?format=raw', file_size, 888 int(time.time()),'', self.author, 'e-mail') ) 889 890 # Attachment is already known 891 # 892 except sqlite.IntegrityError: 893 #self.db.close() 894 return count 895 896 self.db.commit() 897 898 else: 899 fd = open(path) 900 att = attachment.Attachment(self.env, 'ticket', ticket['id']) 901 902 # This will break the ticket_update system, the body_text is vaporized 903 # ;-( 904 # 905 if not update: 906 att.author = self.author 907 att.description = self.email_to_unicode('Added by email2trac') 908 909 att.insert(url_filename, fd, file_size) 910 911 #except util.TracError, detail: 912 # print detail 913 914 fd.close() 864 fd = open(path) 865 att = attachment.Attachment(self.env, 'ticket', ticket['id']) 866 867 # This will break the ticket_update system, the body_text is vaporized 868 # ;-( 869 # 870 if not update: 871 att.author = self.author 872 att.description = self.email_to_unicode('Added by email2trac') 873 874 att.insert(url_filename, fd, file_size) 875 #except util.TracError, detail: 876 # print detail 915 877 916 878 # Remove the created temporary filename 917 879 # 880 fd.close() 918 881 os.unlink(path) 919 882 … … 1020 983 1021 984 try: 1022 if version == 0.8: 1023 from trac.Environment import Environment 1024 from trac.Ticket import Ticket 1025 from trac.Notify import TicketNotifyEmail 1026 from trac.Href import Href 1027 from trac import util 1028 import sqlite 1029 elif version == 0.9: 985 if version == 0.9: 1030 986 from trac import attachment 1031 987 from trac.env import Environment
Note: See TracChangeset
for help on using the changeset viewer.