Changeset 416
- Timestamp:
- 07/21/10 08:23:20 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/email2trac.py.in
r415 r416 365 365 # 366 366 if self.DROP_SPAM and spam: 367 if self.parameters.debug > 2 : 368 set.logger.debug('Message is a SPAM. Automatic ticket insertion refused (SPAM level > %d)' % self.SPAM_LEVEL) 369 367 368 set.logger.info('Message is a SPAM. Automatic ticket insertion refused (SPAM level > %d)' % self.SPAM_LEVEL) 370 369 return 'drop' 371 370 … … 373 372 374 373 return 'Spam' 375 376 374 else: 377 375 … … 394 392 395 393 except KeyError, detail: 396 if self.parameters.debug > 2 : 397 self.logger.debug('%s not defined, all messages are allowed.' %(keyword)) 394 self.logger.debug('%s not defined, all messages are allowed.' %(keyword)) 398 395 399 396 return default … … 505 502 506 503 if addr == self.trac_smtp_from: 507 if self.parameters.debug: 508 self.logger.debug("Skipping %s mail address for CC-field" %(addr)) 504 self.logger.debug("Skipping %s mail address for CC-field" %(addr)) 509 505 continue 510 506 … … 515 511 516 512 if email_cc: 517 if self.parameters.debug: 518 self.logger.debug('set_reply_fields: %s' %email_cc) 513 self.logger.debug('set_reply_fields: %s' %email_cc) 519 514 520 515 ticket['cc'] = self.email_to_unicode(email_cc) … … 709 704 710 705 if tkt['reporter'].lower() in [self.author, self.email_addr]: 711 if self.parameters.debug: 712 self.logger.debug('ALLOW, %s is the ticket reporter' %(self.email_addr)) 706 self.logger.debug('ALLOW, %s is the ticket reporter' %(self.email_addr)) 713 707 714 708 return True … … 716 710 perm = PermissionSystem(self.env) 717 711 if perm.check_permission('TICKET_MODIFY', self.author): 718 if self.parameters.debug: 719 self.logger.debug('ALLOW, %s has trac permission to update the ticket' %(self.author)) 712 self.logger.debug('ALLOW, %s has trac permission to update the ticket' %(self.author)) 720 713 721 714 return True … … 730 723 for cc in cc_list: 731 724 if self.email_addr.lower() in cc.strip(): 732 733 if self.parameters.debug: 734 self.logger.debug('ALLOW, %s is in the CC' %(self.email_addr)) 725 self.logger.debug('ALLOW, %s is in the CC' %(self.email_addr)) 735 726 736 727 return True … … 811 802 812 803 if self.trac_smtp_from in cc_list: 813 if self.parameters.debug: 814 self.logger.debug('TD: MAIL LOOP: %s is not allowed as CC address' %(self.trac_smtp_from)) 804 self.logger.debug('TD: MAIL LOOP: %s is not allowed as CC address' %(self.trac_smtp_from)) 815 805 816 806 cc_list.remove(self.trac_smtp_from) … … 930 920 fields = controller.get_ticket_changes(req, tkt, self.WORKFLOW) 931 921 932 if self.parameters.debug: 933 self.logger.debug('Workflow ticket update fields: ') 922 self.logger.debug('Workflow ticket update fields: ') 934 923 935 924 for key in fields.keys(): 936 if self.parameters.debug: 937 self.logger.debug('\t %s : %s' %(key, fields[key])) 938 925 self.logger.debug('\t %s : %s' %(key, fields[key])) 939 926 tkt[key] = fields[key] 940 927 … … 1006 993 1007 994 if self.parameters.debug: 1008 s = ' TD: trac.ini name %s= %s' %(name, value)995 s = 'trac[%s] = %s' %(name, value) 1009 996 self.print_unicode(s) 1010 997 … … 1015 1002 value = self.parameters['%s_%s' %(prefix, name)] 1016 1003 if self.parameters.debug > 10: 1017 s = ' TD: email2trac.conf %s= %s ' %(name, value)1004 s = 'email2trac[%s] = %s ' %(name, value) 1018 1005 self.print_unicode(s) 1019 1006 … … 1022 1009 1023 1010 if self.parameters.debug: 1024 s = ' TD: user_dict[%s]= %s' %(name, value)1011 s = 'used %s = %s' %(name, value) 1025 1012 self.print_unicode(s) 1026 1013 … … 1055 1042 orig_subject = result.group(3) 1056 1043 1057 if self.parameters.debug: 1058 self.logger.debug('subject search string: %s' %(orig_subject)) 1044 self.logger.debug('subject search string: %s' %(orig_subject)) 1059 1045 1060 1046 cursor = self.db.cursor() … … 1068 1054 1069 1055 for summary in summaries: 1070 if self.parameters.debug: 1071 self.logger.debug('Looking for summary matching: "%s"' % summary) 1056 self.logger.debug('Looking for summary matching: "%s"' % summary) 1072 1057 1073 1058 sql = """SELECT id FROM ticket … … 1079 1064 (matched_id,) = row 1080 1065 1081 if self.parameters.debug: 1082 self.logger.debug('Found matching ticket id: %d' % matched_id) 1066 self.logger.debug('Found matching ticket id: %d' % matched_id) 1083 1067 1084 1068 break … … 1335 1319 from trac.util.datefmt import to_timestamp, utc 1336 1320 1337 if self.parameters.debug: 1338 self.logger.debug('Creating a new topic in forum:', self.id) 1321 self.logger.debug('Creating a new topic in forum:', self.id) 1339 1322 1340 1323 # Get dissussion API component. … … 1345 1328 forum = api.get_forum(context, self.id) 1346 1329 1347 if not forum and self.parameters.debug:1348 self.logger. debug("ERROR: Replied forum doesn't exist")1330 if not forum: 1331 self.logger.error("ERROR: Replied forum doesn't exist") 1349 1332 1350 1333 # Prepare topic. … … 1366 1349 from trac.util.datefmt import to_timestamp, utc 1367 1350 1368 if self.parameters.debug: 1369 self.logger.debug('Replying to discussion topic', self.id) 1351 self.logger.debug('Replying to discussion topic', self.id) 1370 1352 1371 1353 # Get dissussion API component. … … 1376 1358 topic = api.get_topic(context, self.id) 1377 1359 1378 if not topic and self.parameters.debug:1379 self.logger. debug("ERROR: Replied topic doesn't exist")1360 if not topic: 1361 self.logger.error("ERROR: Replied topic doesn't exist") 1380 1362 1381 1363 # Prepare message. … … 1397 1379 from trac.util.datefmt import to_timestamp, utc 1398 1380 1399 if self.parameters.debug: 1400 self.loggger.debug('TD: Replying to discussion message', self.id) 1381 self.loggger.debug('TD: Replying to discussion message', self.id) 1401 1382 1402 1383 # Get dissussion API component. … … 1407 1388 message = api.get_message(context, self.id) 1408 1389 1409 if not message and self.parameters.debug:1410 self.logger. debug("ERROR: Replied message doesn't exist")1390 if not message: 1391 self.logger.error("ERROR: Replied message doesn't exist") 1411 1392 1412 1393 # Prepare message. … … 1529 1510 1530 1511 if not m: 1531 if self.parameters.debug: 1532 self.logger.debug('This is not a valid email message format') 1533 1512 self.logger.debug('This is not a valid email message format') 1534 1513 return 1535 1514 … … 1547 1526 1548 1527 if not self.email_header_acl('white_list', self.email_addr, True): 1549 if self.parameters.debug: 1550 self.logger.debug('Message rejected : %s not in white list' %(self.email_addr)) 1551 1528 self.logger.info('Message rejected : %s not in white list' %(self.email_addr)) 1552 1529 return False 1553 1530 1554 1531 if self.email_header_acl('black_list', self.email_addr, False): 1555 if self.parameters.debug: 1556 self.logger.debug('Message rejected : %s in black list' %(self.email_addr)) 1557 1532 self.logger.info('Message rejected : %s in black list' %(self.email_addr)) 1558 1533 return False 1559 1534 1560 1535 if not self.email_header_acl('recipient_list', self.to_email_addr, True): 1561 if self.parameters.debug: 1562 self.logger.debug('Message rejected : %s not in recipient list' %(self.to_email_addr)) 1563 1536 self.logger.info('Message rejected : %s not in recipient list' %(self.to_email_addr)) 1564 1537 return False 1565 1538 … … 1579 1552 subject = self.email_to_unicode(m['Subject']) 1580 1553 1581 if self.parameters.debug: 1582 self.logger.debug('subject: %s' %subject) 1554 self.logger.debug('subject: %s' %subject) 1583 1555 1584 1556 # … … 1754 1726 self.properties[keyword] = value.strip() 1755 1727 1756 if self.parameters.debug:1757 self.logger.debug('inline properties: %s : %s' %(keyword,value)) 1728 self.logger.debug('inline properties: %s : %s' %(keyword,value)) 1729 1758 1730 else: 1759 1731 body.append(line) … … 1807 1779 1808 1780 for part in msg.walk(): 1809 if self.parameters.debug: 1810 self.logger.debug('Message part: Main-Type: %s' % part.get_content_maintype()) 1811 self.logger.debug('Message part: Content-Type: %s' % part.get_content_type()) 1781 self.logger.debug('Message part: Main-Type: %s' % part.get_content_maintype()) 1782 self.logger.debug('Message part: Content-Type: %s' % part.get_content_type()) 1812 1783 1813 1784 ## Check content type 1814 1785 # 1815 1786 if part.get_content_type() in self.STRIP_CONTENT_TYPES: 1816 1817 if self.parameters.debug: 1818 self.logger.debug("A %s attachment named '%s' was skipped" %(part.get_content_type(), part.get_filename())) 1819 1787 self.logger.debug("A %s attachment named '%s' was skipped" %(part.get_content_type(), part.get_filename())) 1820 1788 continue 1821 1789 … … 1829 1797 # 1830 1798 if part.get_content_maintype() == 'multipart': 1831 if self.parameters.debug:1832 self.logger.debug("Skipping multipart container") 1799 self.logger.debug("Skipping multipart container") 1800 1833 1801 continue 1834 1802 … … 1841 1809 if ALTERNATIVE_MULTIPART and self.DROP_ALTERNATIVE_HTML_VERSION: 1842 1810 if part.get_content_type() == 'text/html': 1843 if self.parameters.debug: 1844 self.logger.debug('Skipping alternative HTML message') 1845 1846 ALTERNATIVE_MULTIPART = False 1811 self.logger.debug('Skipping alternative HTML message') 1812 ALTERNATIVE_MULTIPART = False 1847 1813 continue 1848 1814 … … 1850 1816 # 1851 1817 if part.get_content_type() == 'text/plain' and inline: 1852 if self.parameters.debug: 1853 self.logger.debug(' Inline body part') 1818 self.logger.debug(' Inline body part') 1854 1819 1855 1820 # Try to decode, if fails then do not decode
Note: See TracChangeset
for help on using the changeset viewer.