Ignore:
Timestamp:
04/24/07 07:52:46 (17 years ago)
Author:
bas
Message:

EmailToTracScript?
EmailtoTracScript?:

email2trac.py.in:

  • Some bugfixes for attachments that are too big
Location:
emailtotracscript/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • emailtotracscript/trunk/ChangeLog

    r151 r152  
    1 2007-03-09
     12007-XXXXX
    22
    33        * Added some primarily check to catch an error when attachment size
     
    1313          Author: Rainer Sokoll (r.sokoll at intershop dot de)
    1414
    15 
    16 2007-03-08 Michel Jouvin <jouvin@lal.in2p3.fr>
    1715        * email2trac.py : blacklist (don't create ticket) mail from
    1816          MAILER-DAEMON to avoid loops
     17          Author: Michel Jouvin <jouvin at lal dot in2p3 dot fr>
     18
    1919        * msg.bad.txt : add an example of message from MAILER-DAEMON
     20          Author: Michel Jouvin <jouvin at lal dot in2p3 dot fr>
    2021
    21222006-12-08
  • emailtotracscript/trunk/email2trac.py.in

    r151 r152  
    4141
    4242        * From:      => Reporter
    43                      => CC (Optional via reply_address option)
     43                     => CC (Optional via reply_all option)
    4444        * Subject:   => Summary
    4545        * Body       => Description
     
    5353        debug        : 1               # OPTIONAL, if set print some DEBUG info
    5454        spam_level   : 4               # OPTIONAL, if set check for SPAM mail
    55         reply_address: 1               # OPTIONAL, if set then fill in ticket CC field
     55        reply_all    : 1               # OPTIONAL, if set then fill in ticket CC field
    5656        umask        : 022             # OPTIONAL, if set then use this umask for creation of the attachments
    5757        mailto_link  : 1               # OPTIONAL, if set then [mailto:<>] in description
     
    416416
    417417                if self.VERSION  == 0.9:
    418                         self.attachments(m, tkt, True)
    419                 else:
    420                         self.attachments(m, tkt)
     418                        str = self.attachments(m, tkt, True)
     419                else:
     420                        str = self.attachments(m, tkt)
    421421
    422422                if self.notification:
     
    492492                                %(head, mailto, body_text)
    493493
    494                 n =  self.attachments(msg, tkt)
    495                 if n:
     494                str =  self.attachments(msg, tkt)
     495                if str:
    496496                        changed = True
    497                         comment = '%s\nThis message has %d attachment(s)\n' %(comment, n)
     497                        comment = '%s\n%s\n' %(comment, str)
    498498
    499499                if changed:
     
    522522                self.db = self.env.get_db_cnx()
    523523                self.get_author_emailaddrs(m)
     524
    524525                if self.blacklisted_from():
    525526                        if self.DEBUG > 1 :
     
    692693                first = 0
    693694                number = 0
     695
     696                # Get Maxium attachment size
     697                #
     698                max_size = int(self.get_config('attachment', 'max_size'))
     699                message = ''
     700
    694701                for part in message.walk():
    695702                        if part.get_content_maintype() == 'multipart':          # multipart/* is just a container
     
    702709
    703710                        filename = part.get_filename()
    704                         count = count + 1
    705711                        if not filename:
    706712                                number = number + 1
     
    751757                        filesize = stats[stat.ST_SIZE]
    752758
     759                        # Check if the attachment size is allowed
     760                        #
     761                        if file_size > max_size:
     762                                message = '%s\n%sFile %s is larger then allowed attachment size (%d > %d)'
     763                                        %(message, filename, file_size, max_size)
     764
     765                                os.unlink(path)
     766                                continue
     767                        else:
     768                                count = count + 1
     769                                       
    753770                        # Insert the attachment it differs for the different TRAC versions
    754771                        #
     
    779796                                        att.description = self.email_to_unicode('Added by email2trac')
    780797
    781                                 try:
    782                                         att.insert(url_filename, fd, filesize)
    783                                 except  util.TracError, detail:
    784                                         a =  1
     798                                att.insert(url_filename, fd, filesize)
     799
     800                                #except  util.TracError, detail:
     801                                #       print detail
    785802
    786803                                fd.close()
     
    792809                # Return how many attachments
    793810                #
    794                 return count
     811                message = 'This message has %d attachment(s)\n%s' %(count, message)
     812                return message
    795813
    796814
Note: See TracChangeset for help on using the changeset viewer.