Changeset 549
- Timestamp:
- 08/11/11 14:06:22 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/email2trac.py.in
r548 r549 633 633 return parsed_data 634 634 635 def check_filename_length(self, name): 636 """ 637 check if the filename lenght is not larger the OS limit 638 yes : return truncated filename 639 no : return unmodified filename 640 """ 641 self.logger.debug('function check_filename_length: ') 642 643 dummy_filename, ext = os.path.splitext(name) 644 645 ## Trac uses this format 646 # 647 quote_format = util.text.unicode_quote(dummy_filename) 648 649 ## Determine max filename lenght 650 # 651 filemax_length = os.pathconf('/', os.pathconf_names['PC_NAME_MAX']) 652 653 if len(quote_format) <= filemax_length: 654 return name 655 656 else: 657 ## Truncate file to filemax_length and reserve room for extension 658 # We must break on a boundry 659 # 660 length = filemax_length - 6 661 662 for i in range(0,10): 663 664 truncated = quote_format[ : (length - i)] 665 666 try: 667 unqoute_truncated = util.text.unicode_unquote(truncated) 668 unqoute_truncated = unqoute_truncated + ext 669 670 self.print_unicode('\t ' + unqoute_truncated) 671 672 break 673 674 except UnicodeDecodeError, detail: 675 continue 676 677 678 return unqoute_truncated 679 635 680 ########## TRAC ticket functions ########################################################### 636 681 … … 785 830 # system one's 786 831 # 787 for field,value in user_dict.items(): 788 789 if self.parameters.debug: 790 s = 'user_field\t %s = %s' %(field,value) 791 self.print_unicode(s) 832 for field,value in user_dict.items(): 833 834 s = 'user_field\t %s = %s' %(field,value) 835 self.print_unicode(s) 792 836 793 837 if not field in sys_dict.keys(): … … 828 872 ticket[field] = value 829 873 830 if self.parameters.debug: 831 s = 'ticket_field\t %s = %s' %(field, ticket[field]) 832 self.print_unicode(s) 874 s = 'ticket_field\t %s = %s' %(field, ticket[field]) 875 self.print_unicode(s) 833 876 834 877 def ticket_update(self, m, id, spam): … … 985 1028 value = options[int(value)] 986 1029 987 if self.parameters.debug: 988 s = 'trac[%s] = %s' %(name, value) 989 self.print_unicode(s) 1030 s = 'trac[%s] = %s' %(name, value) 1031 self.print_unicode(s) 990 1032 991 1033 ## email2trac.conf settings … … 994 1036 try: 995 1037 value = self.parameters['%s_%s' %(prefix, name)] 996 if self.parameters.debug: 997 998 1038 1039 s = 'email2trac[%s] = %s ' %(name, value) 1040 self.print_unicode(s) 999 1041 1000 1042 except KeyError, detail: … … 1269 1311 att.description = self.email_to_unicode('Added by email2trac') 1270 1312 1313 ## Pseudo code to determine max filename lenght 1314 # os.pathconf('/', os.pathconf_name['PC_NAME_MAX']) 1315 1271 1316 try: 1272 1317 self.logger.debug('Insert atachment') … … 1539 1584 ## Attach attachments. 1540 1585 # 1541 self.id = message['topic'] 1586 1542 1587 self.attach_attachments(context.content_parts, True) 1543 1588 … … 1894 1939 1895 1940 filename = part.get_filename() 1896 if self.parameters.debug:1897 1898 1899 1941 1942 s = '\t unicode filename: %s' %(filename) 1943 self.print_unicode(s) 1944 self.logger.debug('\t raw filename: %s' %repr(filename)) 1900 1945 1901 1946 # 11 Aug 2011 -> Obsolete code … … 1912 1957 # filename = part.get_filename() 1913 1958 1914 message_parts.append( (filename, part))1959 message_parts.append( (self.check_filename_length(filename), part) ) 1915 1960 1916 1961 ## We van only convert html messages … … 2045 2090 unique_filename = "%s-%s%s" % (dummy_filename, num, ext) 2046 2091 2047 if self.parameters.debug: 2048 s = 'Attachment with filename %s will be saved as %s' % (filename, unique_filename) 2049 self.print_unicode(s) 2092 s = 'Attachment with filename %s will be saved as %s' % (filename, unique_filename) 2093 self.print_unicode(s) 2050 2094 2051 2095 attachment_names.add(unique_filename) … … 2058 2102 def attachment_exists(self, filename): 2059 2103 2060 if self.parameters.debug: 2061 s = 'attachment already exists: Id : %s, Filename : %s' %(self.id, filename) 2062 self.print_unicode(s) 2104 self.logger.debug("function attachment_exists") 2105 2106 s = '\t check if attachment already exists: Id : %s, Filename : %s' %(self.id, filename) 2107 self.print_unicode(s) 2063 2108 2064 2109 ## We have no valid ticket id
Note: See TracChangeset
for help on using the changeset viewer.