Changeset 169


Ignore:
Timestamp:
Feb 9, 2006 1:54:10 PM (16 years ago)
Author:
dkearney
Message:

removed manual creation of badly named temp files and replaced
with the python module tempfile which creates uniquely named
tempfiles and cleans them up.

this fixes error where you two people try to run rerun at the
same time and the second instance fails with crazy errors.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/apps/rerun

    r145 r169  
    3535"""
    3636
    37 import getopt, shutil, re, os, sys
     37import getopt, shutil, re, os, sys, tempfile
    3838
    3939def printHelp():
     
    7373
    7474    # prepare text variables
    75     outTmpFileName = '/tmp/rerun_' + os.path.basename(runFile)
    76     outCmd = '<command>echo =RAPPTURE-RUN=>%s</command>' % outTmpFileName
     75    myTmpFile = tempfile.NamedTemporaryFile()
     76    outCmd = '<command>echo =RAPPTURE-RUN=>%s</command>' % myTmpFile.name
    7777
    7878    # do the file <command> switheroo!
    7979    xmlfile = open(runFile, "rb").read()
    80     tmpfile = open(outTmpFileName, "wb")
    8180    outText = re_command.sub(outCmd,xmlfile)
    82     tmpfile.write(outText)
    83     tmpfile.close()
     81    myTmpFile.write(outText)
     82    myTmpFile.flush()
    8483
    8584    # run driver on the temporary run file
    86     systemCmd = '%s -tool %s' % (driverPath, outTmpFileName)
     85    print "myTmpFile.name = %s" % (myTmpFile.name)
     86    systemCmd = '%s -tool %s' % (driverPath, myTmpFile.name)
    8787    os.system(systemCmd)
    88    
    89     # presto-change-o 
    90    
     88
     89    # presto-change-o
     90
    9191    # clean up our tmp file
    92     os.remove(outTmpFileName)
     92    # the tempfile module deletes the file automatically when closed
     93    myTmpFile.close()
     94
     95    # exit gracefully
    9396    sys.exit()
Note: See TracChangeset for help on using the changeset viewer.