Changeset 68


Ignore:
Timestamp:
05/16/06 11:13:13 (18 years ago)
Author:
bas
Message:

EmailtoTracScript?:

email2trac.py.in:

  • Added support for version 0.10

ChangeLog?:

  • See Changelog
Location:
emailtotracscript/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • emailtotracscript/trunk/ChangeLog

    r64 r68  
    1 2006-04-??
     12006-05-16
    22        - Fixed a bug when there was no plain text body.
    33          Reported by: Greg Deakyne
    44        - Fixed a small bug if default component owner is unknown.
    55          Just fill in some bogus info.
    6         - Use the short options for the install command. S it works for
     6        - Use the short options for the install command. So it works for
    77          MacOSx
    88          Reported by: Nathaniel Irons
     9        - Messages that has X-Virus-found in header are marked as SPAM
     10          Implemented by: Walter de Jong
     11        - Some modules are changed for version 0.10, Added and made some
     12          minor changes: Patch supplied by: Markus Tacker 
    913
    1014
  • emailtotracscript/trunk/email2trac.py.in

    r67 r68  
    5252        spam_level   : 4                 # OPTIONAL, if set check for SPAM mail
    5353        reply_address: 1                 # OPTIONAL, if set then fill in ticket CC field
    54         umask        : 022               # OPTIONAL, if set then use this umask for creation of the attachments
     54    umask        : 022               # OPTIONAL, if set then use this umask for creation of the attachments
    5555        mailto_link  : 1                 # OPTIONAL, if set then [mailto:<CC>] in description
    5656        trac_version : 0.8               # OPTIONAL, default is 0.9
     
    100100
    101101                self.VERSION = version
    102                 if self.VERSION > 0.8:
     102                if self.VERSION == 0.8:
     103                        self.get_config = self.env.get_config
     104                else:
    103105                        self.get_config = self.env.config.get
    104                 else:
    105                         self.get_config = self.env.get_config
    106106
    107107                if parameters.has_key('umask'):
     
    256256                # Look for email address in registered trac users
    257257                #
    258                 if self.VERSION > 0.8:
     258                if self.VERSION == 0.8:
     259                        users = []
     260                else:
    259261                        users = [ u for (u, n, e) in self.env.get_known_users(self.db)
    260262                                if e == email_addr ]
    261                 else:
    262                         users = []
    263263
    264264                if len(users) == 1:
     
    363363                # Insert ticket in database
    364364                #
    365                 if self.VERSION > 0.8:
     365                if self.VERSION == 0.8:
     366                        tkt['id'] = tkt.insert(self.db)
     367                else:
    366368                        tkt['id'] = tkt.insert()
    367                 else:
    368                         tkt['id'] = tkt.insert(self.db)
    369369
    370370                #
     
    509509
    510510                        url_filename = urllib.quote(filename)
    511                         if self.VERSION > 0.8:
    512                                 dir = '/tmp'
    513                         else:
     511                        if self.VERSION == 0.8:
    514512                                dir = os.path.join(self.env.get_attachments_dir(), 'ticket',
    515513                                                        urllib.quote(str(ticket['id'])))
    516514                                if not os.path.exists(dir):
    517515                                        mkdir_p(dir, 0755)
     516                        else:
     517                                dir = '/tmp'
    518518
    519519                        path, fd =  util.create_unique_file(os.path.join(dir, url_filename))
     
    531531                        # Insert the attachment it differs for the different TRAC versions
    532532                        #
    533                         if self.VERSION > 0.8:
    534                                 fd = open(path)
    535                                 att = attachment.Attachment(self.env, 'ticket', ticket['id'])
    536                                 att.insert(url_filename, fd, filesize)
    537                                 fd.close()
    538                         else:
     533                        if self.VERSION == 0.8:
    539534                                cursor = self.db.cursor()
    540535                                cursor.execute('INSERT INTO attachment VALUES("%s","%s","%s",%d,%d,"%s","%s","%s")'
     
    542537                                          int(time.time()),'', user, 'e-mail') )
    543538                                self.db.commit()
     539                        else:
     540                                fd = open(path)
     541                                att = attachment.Attachment(self.env, 'ticket', ticket['id'])
     542                                att.insert(url_filename, fd, filesize)
     543                                fd.close()
    544544
    545545
     
    634634        #print settings
    635635
    636         if version > 0.8:
    637                 from trac import attachment
    638                 from trac.env import Environment
    639                 from trac.ticket import Ticket
    640                 from trac.Notify import TicketNotifyEmail
    641                 from trac.web.href import Href
    642                 from trac import util
    643         else:
     636        if version == 0.8:
    644637                from trac.Environment import Environment
    645638                from trac.Ticket import Ticket
     
    647640                from trac.Href import Href
    648641                from trac import util
     642        elif version == 0.9:
     643                from trac import attachment
     644                from trac.env import Environment
     645                from trac.ticket import Ticket
     646                from trac.web.href import Href
     647                from trac import util
     648                from trac.Notify import TicketNotifyEmail
     649        elif version == 0.10:
     650                from trac import attachment
     651                from trac.env import Environment
     652                from trac.ticket import Ticket
     653                from trac.web.href import Href
     654                from trac import util
     655                # see http://projects.edgewall.com/trac/changeset/2799
     656                from trac.ticket.notification import TicketNotifyEmail
    649657
    650658        env = Environment(settings['project'], create=0)
Note: See TracChangeset for help on using the changeset viewer.