Changeset 553 for trunk/email2trac.py.in
- Timestamp:
- 08/12/11 12:38:06 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/email2trac.py.in
r551 r553 350 350 351 351 ## Only use name or email adress 352 # ticket['reporter'] = self.email_from352 # 353 353 ticket['reporter'] = self.author 354 354 … … 372 372 # to_list.append(e) 373 373 374 # Always Remove reporter email address from cc-list374 ## Always Remove reporter email address from cc-list 375 375 # 376 376 try: … … 383 383 ## Prevent mail loop 384 384 # 385 #if addr in to_list:386 387 385 if addr == self.trac_smtp_from: 388 386 self.logger.debug("Skipping %s mail address for CC-field" %(addr)) … … 419 417 420 418 message_body = message_body.encode('utf-8') 421 #message_body = unicode(message_body, 'iso-8859-15')422 419 423 420 fx.write(message_body) … … 435 432 n = 0 436 433 for item in message_parts: 437 # Skip inline text parts 434 435 ## Skip inline text parts 436 # 438 437 if not isinstance(item, tuple): 439 438 continue … … 461 460 continue 462 461 462 # trac error with long filenames support 463 463 #part_file = util.text.unicode_quote(part_file) 464 464 #part_file = repr(part_file) … … 488 488 fx = os.fdopen(fd, 'wb') 489 489 else: 490 #msg_file = '/var/tmp/msg.txt'491 490 msg_file = os.path.join(self.parameters.tmpdir, 'msg.%s.email2trac' %project_name) 492 491 fx = open(msg_file, 'wb') … … 546 545 s = '%s' %temp 547 546 548 #s = s.encode('utf-8')549 547 return s 550 548 … … 696 694 697 695 except KeyError: 698 ## 699 # fallback for compability (Will be deprecated) 700 # workflow can be none. 696 ## fallback for compability (Will be deprecated) 697 # workflow can be none. 701 698 # 702 699 workflow = None … … 870 867 871 868 else: 872 ## Only set if we have a value 873 # 874 #if value: 875 # ticket[field] = value 869 876 870 ticket[field] = value 877 871 … … 937 931 ## How many changes has this ticket 938 932 # 939 # cnum = len(tkt.get_changelog())940 933 grouped = TicketModule(self.env).grouped_changelog_entries(tkt, self.db) 941 934 cnum = sum(1 for e in grouped) + 1 … … 1125 1118 return (found_id, orig_subject) 1126 1119 1127 # ob esolete !??1120 # obsolete !?? 12 Aug 2011 1128 1121 #subject = orig_subject 1129 1122 … … 1241 1234 else: 1242 1235 tkt.save_changes(tkt['reporter'], comment) 1243 #print tkt.get_changelog(self.db, when)1244 1236 1245 1237 if not spam: … … 1301 1293 fd = open(path, 'rb') 1302 1294 if self.system == 'discussion': 1303 att = attachment.Attachment(self.env, 'discussion', 'topic/%s' 1304 % (self.id,)) 1295 att = attachment.Attachment(self.env, 'discussion', 'topic/%s' % (self.id,)) 1305 1296 else: 1306 1297 s = 'Attach %s to ticket %d' %(filename, self.id) … … 1315 1306 att.description = self.email_to_unicode('Added by email2trac') 1316 1307 1317 ## Pseudo code to determine max filename lenght1318 # os.pathconf('/', os.pathconf_name['PC_NAME_MAX'])1319 1320 1308 try: 1309 1321 1310 self.logger.debug('Insert atachment') 1322 1311 att.insert(filename, fd, file_size) 1312 1323 1313 except OSError, detail: 1314 1324 1315 self.logger.info('%s\nFilename %s could not be saved, problem: %s' %(status, filename, detail)) 1325 1316 status = '%s\nFilename %s could not be saved, problem: %s' %(status, filename, detail) … … 1735 1726 1736 1727 else: 1728 1737 1729 self.system = 'ticket' 1738 1730 (matched_id, subject) = self.ticket_update_by_subject(subject) 1731 1739 1732 if matched_id: 1733 1740 1734 if not self.ticket_update(m, matched_id, spam_msg): 1741 1735 self.new_ticket(m, subject, spam_msg) 1736 1742 1737 else: 1743 1738 ## No update by subject, so just create a new ticket … … 1932 1927 # 1933 1928 if ALTERNATIVE_MULTIPART and self.parameters.drop_alternative_html_version: 1929 1934 1930 if content_type == 'text/html': 1935 1931 self.logger.debug('\t Skipping alternative HTML message') … … 2065 2061 ## Discard relative paths for windows/unix in attachment names 2066 2062 # 2067 #filename = filename.replace('\\', '/').replace(':', '/')2068 2063 filename = filename.replace('\\', '_') 2069 2064 filename = filename.replace('/', '_') … … 2111 2106 self.print_unicode(s) 2112 2107 2113 ## We have novalid ticket id2108 ## Do we have a valid ticket id 2114 2109 # 2115 2110 if not self.id: … … 2118 2113 try: 2119 2114 if self.system == 'discussion': 2120 att = attachment.Attachment(self.env, 'discussion', 'ticket/%s' 2121 % (self.id,), filename) 2115 2116 att = attachment.Attachment(self.env, 'discussion', 'ticket/%s' % (self.id,), filename) 2117 2122 2118 else: 2123 att = attachment.Attachment(self.env, 'ticket', self.id, 2124 filename) 2119 2120 att = attachment.Attachment(self.env, 'ticket', self.id, filename) 2121 2125 2122 return True 2123 2126 2124 except attachment.ResourceNotFound: 2125 2127 2126 return False 2128 2127 … … 2156 2155 2157 2156 if part.get_content_maintype() == 'image' and inline: 2157 2158 2158 if self.system != 'discussion': 2159 2159 s = 'wiki image link for: %s' %(filename) 2160 2160 self.print_unicode(s) 2161 2161 body_text.append('[[Image(%s)]]' % filename) 2162 2162 2163 body_text.append("") 2164 2163 2165 else: 2166 2164 2167 if self.system != 'discussion': 2168 2165 2169 s = 'wiki attachment link for: %s' %(filename) 2166 2170 self.print_unicode(s) 2167 2171 body_text.append('[attachment:"%s"]' % filename) 2172 2168 2173 body_text.append("") 2169 2174
Note: See TracChangeset
for help on using the changeset viewer.