Changeset 514 for trunk/email2trac.py.in


Ignore:
Timestamp:
01/14/11 16:16:55 (13 years ago)
Author:
bas
Message:

changed tempfile.mktemp to tempfile.mkstemp

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/email2trac.py.in

    r509 r514  
    415415    def debug_body(self, message_body, temporary_file=False):
    416416        if temporary_file:
    417             body_file = tempfile.mktemp('.email2trac')
     417            (fd, body_file) = tempfile.mkstemp('.email2trac')
     418            fx = os.fdopen(fd, 'wb')
    418419        else:
    419420            body_file = os.path.join(self.parameters.tmpdir, 'body.txt')
     421            fx = open(body_file, 'wb')
    420422
    421423        if self.parameters.dry_run:
     
    424426
    425427        print 'writing body to %s' %(body_file)
    426         fx = open(body_file, 'wb')
    427428        if not message_body:
    428429                message_body = '(None)'
     
    490491
    491492        if create_tempfile:
    492             msg_file = tempfile.mktemp('.email2trac')
     493            (fd, msg_file) = tempfile.mkstemp('.email2trac')
     494            fx = os.fdopen(fd, 'wb')
    493495        else:
    494496            #msg_file = '/var/tmp/msg.txt'
    495497            msg_file = os.path.join(self.parameters.tmpdir, 'msg.txt')
     498            fx = open(msg_file, 'wb')
    496499
    497500        if self.parameters.dry_run:
     
    500503            print 'saving email to %s' %(msg_file)
    501504
    502             fx = open(msg_file, 'wb')
    503505            fx.write('%s' % message)
    504506            fx.close()
     
    537539                    temp = unicode(text, 'iso-8859-15')
    538540                except LookupError, detail:
    539                     #text = 'ERROR: Could not find charset: %s, please install' %format
     541                    msg = 'ERROR: Could not find charset: %s, please install' %format
     542                    sys.logger.error(msg)
    540543                    #temp = unicode(text, 'iso-8859-15')
    541544                    temp = message_str
     
    614617        parsed_data = None
    615618        if self.parameters.html2text_cmd:
    616             tmp_file = tempfile.mktemp('email2trac.html')
     619            (fd, tmp_file) = tempfile.mkstemp('email2trac.html')
     620            f = os.fdopen(fd, 'w')
     621
    617622            cmd = '%s %s' %(self.parameters.html2text_cmd, tmp_file)
    618623            self.logger.debug('\t html2text conversion %s'%(cmd))
     
    622627
    623628            else:
    624                 f = open(tmp_file, "w+")
    625629                f.write(data)
    626630                f.close()
Note: See TracChangeset for help on using the changeset viewer.