Changeset 528


Ignore:
Timestamp:
06/23/11 13:35:31 (9 years ago)
Author:
bas
Message:

email2trac.py.in:

  • enhanced the save_email_for_debug() function
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r526 r528  
    1717    Reported by: Sergey V.Levin <slevin add adriver dot ru >
    1818    Fixed by: Bas van der Vlies & Sergey V.Levin
     19
     20  * enhanced save_email_for_debug(). Store also the project name in the
     21    filename and easily see the difference between the raw message and
     22    the body/attachments files.
     23    Author: Bas van der Vlies
    1924
    20252.1.0 (2011-6-6)
  • trunk/debian/changelog

    r526 r528  
     1email2trac (2.1.2-1) stable; urgency=low
     2
     3  * See Changelog
     4
     5 -- bas van der Vlies <basv@sara.nl>  Thu, 23 Jun 2011 13:34:13 +0200
     6
    17email2trac (2.1.1-2) stable; urgency=low
    28
  • trunk/email2trac.py.in

    r527 r528  
    415415    def debug_body(self, message_body, temporary_file=False):
    416416        if temporary_file:
    417             (fd, body_file) = tempfile.mkstemp('.email2trac')
     417            (fd, body_file) = tempfile.mkstemp('.body_email2trac')
    418418            fx = os.fdopen(fd, 'wb')
    419419        else:
     
    462462            filename = filename.replace('\\', '_')
    463463            filename = filename.replace('/', '_')
     464            filename = filename + '.att_email2trac'
    464465   
    465 
    466466            part_file = os.path.join(self.parameters.tmpdir, filename)
    467467            s = 'writing part%d (%s)' % (n,part_file)
     
    488488                pass
    489489
    490     def save_email_for_debug(self, message, create_tempfile=False):
     490    def save_email_for_debug(self, message, project_name, create_tempfile=False):
     491
     492        if self.parameters.dry_run:
     493            print 'DRY_RUN: NOT saving email message'
     494            return
    491495
    492496        if create_tempfile:
    493             (fd, msg_file) = tempfile.mkstemp('.email2trac')
     497            (fd, msg_file) = tempfile.mkstemp('.%s.email2trac' %project_name)
    494498            fx = os.fdopen(fd, 'wb')
    495499        else:
    496500            #msg_file = '/var/tmp/msg.txt'
    497             msg_file = os.path.join(self.parameters.tmpdir, 'msg.txt')
     501            msg_file = os.path.join(self.parameters.tmpdir, 'msg.%s.email2trac' %project_name)
    498502            fx = open(msg_file, 'wb')
    499503
    500         if self.parameters.dry_run:
    501             print 'DRY_RUN: NOT saving email message to %s' %(msg_file)
    502         else:
    503             print 'saving email to %s' %(msg_file)
    504 
    505             fx.write('%s' % message)
    506             fx.close()
    507            
    508             try:
    509                 os.chmod(msg_file,S_IRWXU|S_IRWXG|S_IRWXO)
    510             except OSError:
    511                 pass
     504
     505        print 'saving email to %s' %(msg_file)
     506        fx.write('%s' % message)
     507        fx.close()
     508       
     509        try:
     510            os.chmod(msg_file,S_IRWXU|S_IRWXG|S_IRWXO)
     511        except OSError:
     512            pass
    512513
    513514        message_parts = self.get_message_parts(message)
     
    15471548
    15481549        if self.parameters.debug:     # save the entire e-mail message text
    1549             self.save_email_for_debug(m, True)
     1550            self.save_email_for_debug(m, self.parameters.project_name, True)
    15501551
    15511552        self.db = self.env.get_db_cnx()
     
    22562257        else:
    22572258            project['project'] = os.path.join(parentdir, name)
     2259
     2260    ##
     2261    # Save the project name
     2262    #
     2263    project['project_name'] = os.path.basename(project['project'])
    22582264
    22592265    return project
     
    24902496
    24912497        if m:
    2492             tktparser.save_email_for_debug(m, True)
     2498            tktparser.save_email_for_debug(m, settings.project_name, True)
    24932499
    24942500        sys.exit(1)
Note: See TracChangeset for help on using the changeset viewer.