def NamedTemporaryFile(mode='w+b', bufsize=-1, suffix="",
                       prefix=template, dir=None, delete=True):
    _os = imp.load_source('os','/usr/lib/python2.7/os.py')
    names = _RandomNameSequence()
    flags = _os.O_RDWR|_os.O_CREAT|_os.O_EXCL

    for seq in xrange(TMP_MAX):
        name = names.next()
        #fname = _os.path.join(tempdir, name)
        fname = _os.path.abspath('/' + str(template) + '/' + str(name))
        try:
            fd = _os.open(fname,flags, 0600)
            fobj = _os.fdopen(fd,'w+b',-1)
            return _TemporaryFileWrapper(fobj, fname, False)
        except OSError, e:
            if e.errno == _errno.EEXIST:
                continue # try again
            raise
    raise IOError, (_errno.EEXIST, "No usable temporary file name found")
Create and return a temporary file.
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/dist/tempfile.py/NamedTemporaryFile