• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python tempfile.mkstemp函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tempfile.mkstemp函数的典型用法代码示例。如果您正苦于以下问题:Python mkstemp函数的具体用法?Python mkstemp怎么用?Python mkstemp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了mkstemp函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: compile_and_load

def compile_and_load(src_files, obj_files=[], cc="g++", flags=["O3", "Wall"], includes=[], links=[], defs=[]):
    """ Compile and load a shared object from a source file
  \param src_files list of source fiels (eg. ['~/src/foo.cc'])
  \param cc the path to the c++ compiler
  \param obj_files name of files to compile (eg. ['~/obj/foo.o'])
  \param flags list of falgs for the compiler (eg. ['O3', 'Wall'])
  \param includes list of directories to include (eg. ['~/includes/'])
  \param links list of libraries to link with (eg. ['pthread', 'gtest'])
  \param defs list of names to define with -D (eg. ['ENABLE_FOO'])
  \return (lib, fin) link to the library and a function to call to close the library
  """
    __, obj_name = tempfile.mkstemp(suffix=".o", dir=TEMP_DIR)
    os.close(__)
    __, lib_name = tempfile.mkstemp(suffix=".so", dir=TEMP_DIR)
    os.close(__)

    compile_bin(obj_name, src_files, cc=cc, flags=flags, includes=includes, links=links, defs=defs, lib=True)
    # add the newly compiled object file to the list of objects for the lib
    obj_files = list(obj_files)
    obj_files.append(obj_name)
    compile_so(lib_name, obj_files, cc=cc, links=links)

    def finalize():
        if os.path.exists(obj_name):
            os.unlink(obj_name)
        if os.path.exists(lib_name):
            os.unlink(lib_name)

    try:
        lib = ctypes.CDLL(lib_name)
        return lib, finalize
    except OSError:
        print "Failed link with library, source files:"
        print ", ".join(src_files)
        raise
开发者ID:bitfort,项目名称:pycpc,代码行数:35,代码来源:cmake.py


示例2: _execute

def _execute(cmds):
    import subprocess
    stderrPath = tempfile.mkstemp()[1]
    stdoutPath = tempfile.mkstemp()[1]
    stderrFile = open(stderrPath, "w")
    stdoutFile = open(stdoutPath, "w")
    # get the os.environ
    env = _makeEnviron()
    # make a string of escaped commands
    cmds = subprocess.list2cmdline(cmds)
    # go
    popen = subprocess.Popen(cmds, stderr=stderrFile, stdout=stdoutFile, env=env, shell=True)
    popen.wait()
    # get the output
    stderrFile.close()
    stdoutFile.close()
    stderrFile = open(stderrPath, "r")
    stdoutFile = open(stdoutPath, "r")
    stderr = stderrFile.read()
    stdout = stdoutFile.read()
    stderrFile.close()
    stdoutFile.close()
    # trash the temp files
    os.remove(stderrPath)
    os.remove(stdoutPath)
    # done
    return stderr, stdout
开发者ID:andyclymer,项目名称:drawbot,代码行数:27,代码来源:scriptTools.py


示例3: print_xcf

 def print_xcf(self, filename_or_obj, *args, **kwargs):
     "Writes the figure to a GIMP XCF image file"
     # If filename_or_obj is a file-like object we need a temporary file for
     # GIMP's output too...
     if is_string(filename_or_obj):
         out_temp_handle, out_temp_name = None, filename_or_obj
     else:
         out_temp_handle, out_temp_name = tempfile.mkstemp(suffix='.xcf')
     try:
         # Create a temporary file and write the "layer" to it as a PNG
         in_temp_handle, in_temp_name = tempfile.mkstemp(suffix='.png')
         try:
             FigureCanvasAgg.print_png(self, in_temp_name, *args, **kwargs)
             run_gimp_script(
                 SINGLE_LAYER_SCRIPT.format(
                     input=quote_string(in_temp_name),
                     output=quote_string(out_temp_name)))
         finally:
             os.close(in_temp_handle)
             os.unlink(in_temp_name)
     finally:
         if out_temp_handle:
             os.close(out_temp_handle)
             # If we wrote the XCF to a temporary file, write its content to
             # the file-like object we were given (the copy is chunked as
             # XCF files can get pretty big)
             with open(out_temp_name, 'rb') as source:
                 for chunk in iter(lambda: source.read(131072), ''):
                     filename_or_obj.write(chunk)
             os.unlink(out_temp_name)
开发者ID:waveform80,项目名称:rastools,代码行数:30,代码来源:xcfwrite.py


示例4: test_pipeline_with_temp

    def test_pipeline_with_temp(self):
        input_f = tempfile.mkstemp(suffix='capsul_input.txt')
        os.close(input_f[0])
        input_name = input_f[1]
        open(input_name, 'w').write('this is my input data\n')
        output_f = tempfile.mkstemp(suffix='capsul_output.txt')
        os.close(output_f[0])
        output_name = output_f[1]
        #os.unlink(output_name)

        try:
            self.pipeline.input_image = input_name
            self.pipeline.output_image = output_name

            # run sequentially
            self.pipeline()

            # test
            self.assertTrue(os.path.exists(output_name))
            self.assertEqual(open(input_name).read(), open(output_name).read())

        finally:
            try:
                os.unlink(input_name)
            except: pass
            try:
                os.unlink(output_name)
            except: pass
开发者ID:VincentFrouin,项目名称:capsul,代码行数:28,代码来源:test_pipeline_with_temp.py


示例5: take_screenshot

    def take_screenshot(self, filename):
        """Take a screenshot and save it to 'filename'"""

        # make sure filename is unicode
        filename = ensure_unicode(filename, "utf-8")

        if get_platform() == "windows":
            # use win32api to take screenshot
            # create temp file
            
            f, imgfile = tempfile.mkstemp(u".bmp", filename)
            os.close(f)
            mswin.screenshot.take_screenshot(imgfile)
        else:
            # use external app for screen shot
            screenshot = self.get_external_app("screen_shot")
            if screenshot is None or screenshot.prog == "":
                raise Exception(_("You must specify a Screen Shot program in Application Options"))

            # create temp file
            f, imgfile = tempfile.mkstemp(".png", filename)
            os.close(f)

            proc = subprocess.Popen([screenshot.prog, imgfile])
            if proc.wait() != 0:
                raise OSError("Exited with error")

        if not os.path.exists(imgfile):
            # catch error if image is not created
            raise Exception(_("The screenshot program did not create the necessary image file '%s'") % imgfile)

        return imgfile  
开发者ID:brotchie,项目名称:keepnote,代码行数:32,代码来源:__init__.py


示例6: run_shell_cmd

def run_shell_cmd(cmd, echo=True):
    """
    Run a command in a sub-shell, capturing stdout and stderr
    to temporary files that are then read.
    """
    _, stdout_f = tempfile.mkstemp()
    _, stderr_f = tempfile.mkstemp()

    print("Running command")
    print(cmd)
    p = subprocess.Popen(
        '{} >{} 2>{}'.format(cmd, stdout_f, stderr_f), shell=True)
    p.wait()

    with open(stdout_f) as f:
        stdout = f.read()
    os.remove(stdout_f)

    with open(stderr_f) as f:
        stderr = f.read()
    os.remove(stderr_f)

    if echo:
        print("stdout:")
        print(stdout)
        print("stderr:")
        print(stderr)

    return stdout, stderr
开发者ID:CV-IP,项目名称:vislab,代码行数:29,代码来源:util.py


示例7: test_cache

    def test_cache(self):
        """Test the caching mechanism in the reporter."""
        length = random.randint(1, 30)
        exit_code = random.randint(0, 3)
        threshold = random.randint(0, 10)

        message = ''.join(random.choice(string.printable) for x in range(length))
        message = message.rstrip()

        (handle, filename) = tempfile.mkstemp()
        os.unlink(filename)
        os.close(handle)
        reporter = NagiosReporter('test_cache', filename, threshold, self.nagios_user)

        nagios_exit = [NAGIOS_EXIT_OK, NAGIOS_EXIT_WARNING, NAGIOS_EXIT_CRITICAL, NAGIOS_EXIT_UNKNOWN][exit_code]

        reporter.cache(nagios_exit, message)

        (handle, output_filename) = tempfile.mkstemp()
        os.close(handle)

        try:
            old_stdout = sys.stdout
            buffer = StringIO.StringIO()
            sys.stdout = buffer
            reporter_test = NagiosReporter('test_cache', filename, threshold, self.nagios_user)
            reporter_test.report_and_exit()
        except SystemExit, err:
            line = buffer.getvalue().rstrip()
            sys.stdout = old_stdout
            buffer.close()
            self.assertTrue(err.code == nagios_exit[0])
            self.assertTrue(line == "%s %s" % (nagios_exit[1], message))
开发者ID:wpoely86,项目名称:vsc-utils,代码行数:33,代码来源:nagios.py


示例8: cmpIgProfReport

def cmpIgProfReport(outdir,file1,file2,IgProfMemOpt=""):
    (tfile1, tfile2) = ("", "")
    try:
        # don't make temp files in /tmp because it's never bloody big enough
        (th1, tfile1) = tmp.mkstemp(prefix=os.path.join(outdir,"igprofRegressRep."))
        (th2, tfile2) = tmp.mkstemp(prefix=os.path.join(outdir,"igprofRegressRep."))
        os.close(th1)
        os.close(th2)
        os.remove(tfile1)
        os.remove(tfile2)
        ungzip2(file1,tfile1)
        ungzip2(file2,tfile2)        

        perfreport(1,tfile1,tfile2,outdir,IgProfMemOpt)

        os.remove(tfile1)
        os.remove(tfile2)
    except OSError as detail:
        raise PerfReportErr("WARNING: The OS returned the following error when comparing %s and %s\n%s" % (file1,file2,str(detail)))
        if os.path.exists(tfile1):
            os.remove(tfile1)
        if os.path.exists(tfile2):
            os.remove(tfile2)
    except IOError as detail:
        raise PerfReportErr("IOError: When comparing %s and %s using temporary files %s and %s. Error message:\n%s" % (file1,file2,tfile1,tfile2,str(detail)))
        if os.path.exists(tfile1):
            os.remove(tfile1)
        if os.path.exists(tfile2):
            os.remove(tfile2)        
开发者ID:Andrej-CMS,项目名称:cmssw,代码行数:29,代码来源:cmsPerfRegress.py


示例9: shellScriptInWindow

def shellScriptInWindow(c,script):

    if sys.platform == 'darwin':
        #@        << write script to temporary MacOS file >>
        #@+node:ekr.20040915105758.22:<< write script to temporary MacOS file >>
        handle, path = tempfile.mkstemp(text=True)
        directory = c.frame.openDirectory
        script = ("cd %s\n" % directory) + script + '\n' + ("rm -f %s\n" % path)
        os.write(handle, script)
        os.close(handle)
        os.chmod(path, 0700)
        #@nonl
        #@-node:ekr.20040915105758.22:<< write script to temporary MacOS file >>
        #@nl
        os.system("open -a /Applications/Utilities/Terminal.app " + path)

    elif sys.platform == 'win32':
        g.es("shellScriptInWindow not ready for Windows",color='red')

    else:
        #@        << write script to temporary Unix file >>
        #@+node:ekr.20040915105758.25:<< write script to temporary Unix file >>
        handle, path = tempfile.mkstemp(text=True)
        directory = c.frame.openDirectory
        script = ("cd %s\n" % directory) + script + '\n' + ("rm -f %s\n" % path)
        os.write(handle, script)
        os.close(handle)
        os.chmod(path, 0700)
        #@nonl
        #@-node:ekr.20040915105758.25:<< write script to temporary Unix file >>
        #@nl
        os.system("xterm -e sh  " + path)
开发者ID:leo-editor,项目名称:leo-cvs-2002-2006,代码行数:32,代码来源:FileActions.py


示例10: tempfilter

def tempfilter(s, cmd):
    '''filter string S through a pair of temporary files with CMD.
    CMD is used as a template to create the real command to be run,
    with the strings INFILE and OUTFILE replaced by the real names of
    the temporary files generated.'''
    inname, outname = None, None
    try:
        infd, inname = tempfile.mkstemp(prefix='hg-filter-in-')
        fp = os.fdopen(infd, 'wb')
        fp.write(s)
        fp.close()
        outfd, outname = tempfile.mkstemp(prefix='hg-filter-out-')
        os.close(outfd)
        cmd = cmd.replace('INFILE', inname)
        cmd = cmd.replace('OUTFILE', outname)
        code = os.system(cmd)
        if sys.platform == 'OpenVMS' and code & 1:
            code = 0
        if code:
            raise Abort(_("command '%s' failed: %s") %
                        (cmd, explain_exit(code)))
        return open(outname, 'rb').read()
    finally:
        try:
            if inname:
                os.unlink(inname)
        except:
            pass
        try:
            if outname:
                os.unlink(outname)
        except:
            pass
开发者ID:iluxa-c0m,项目名称:mercurial-crew-tonfa,代码行数:33,代码来源:util.py


示例11: svg_formatter

def svg_formatter(data, format) : 
    """ Generate a logo in Scalable Vector Graphics (SVG) format.
    Requires the program 'pdf2svg' be installed.
    """
    pdf = pdf_formatter(data, format)
    
    try:
        command = find_command('pdf2svg')
    except EnvironmentError:
        raise EnvironmentError("Scalable Vector Graphics (SVG) format requires the program 'pdf2svg'. "
                               "Cannot find 'pdf2svg' on search path.")

    import tempfile
    fpdfi, fname_pdf = tempfile.mkstemp(suffix=".pdf")
    fsvgi, fname_svg = tempfile.mkstemp(suffix=".svg")
    try:
        

        fpdf2 = open(fname_pdf, 'w')
        if sys.version_info[0] >= 3:
            fpdf2.buffer.write(pdf)
        else: 
            fpdf2.write(pdf)        
                    
        fpdf2.seek(0)
  
        args = [command, fname_pdf, fname_svg]
        p = Popen(args)
        (out,err) = p.communicate() 

        fsvg = open(fname_svg)
        return fsvg.read().encode()
    finally:
        os.remove(fname_svg)
        os.remove(fname_pdf)
开发者ID:go-bears,项目名称:GSOC_2015,代码行数:35,代码来源:__init__.py


示例12: dump_to_file

def dump_to_file(blurb, exit_fpr):
    """
    Dump the given blurb to a randomly generated file which contains exit_fpr.

    This function is useful to save data obtained from bad exit relays to file
    for later analysis.
    """
    if analysis_dir is None:
        fd, file_name = tempfile.mkstemp(prefix="%s_" % exit_fpr)

    else:
        try:
            os.makedirs(analysis_dir)
        except OSError as err:
            if err.errno != errno.EEXIST:
                raise
        fd, file_name = tempfile.mkstemp(prefix="%s_" % exit_fpr,
                                         dir=analysis_dir)

    try:
        with open(file_name, "w") as fd:
            fd.write(blurb)
    except IOError as err:
        log.warning("Couldn't write to \"%s\": %s" % (file_name, err))
        return None

    log.debug("Wrote %d-length blurb to file \"%s\"." %
                 (len(blurb), file_name))

    return file_name
开发者ID:frankcash,项目名称:exitmap,代码行数:30,代码来源:util.py


示例13: _inject_admin_password_into_fs

def _inject_admin_password_into_fs(admin_passwd, fs):
    """Set the root password to admin_passwd

    admin_password is a root password
    fs is the path to the base of the filesystem into which to inject
    the key.

    This method modifies the instance filesystem directly,
    and does not require a guest agent running in the instance.

    """
    # The approach used here is to copy the password and shadow
    # files from the instance filesystem to local files, make any
    # necessary changes, and then copy them back.

    LOG.debug(_("Inject admin password fs=%(fs)s "
                "admin_passwd=ha-ha-not-telling-you") %
              locals())
    admin_user = 'root'

    fd, tmp_passwd = tempfile.mkstemp()
    os.close(fd)
    fd, tmp_shadow = tempfile.mkstemp()
    os.close(fd)

    passwd_path = os.path.join('etc', 'passwd')
    shadow_path = os.path.join('etc', 'shadow')

    passwd_data = fs.read_file(passwd_path)
    shadow_data = fs.read_file(shadow_path)

    new_shadow_data = _set_passwd(admin_user, admin_passwd,
                                  passwd_data, shadow_data)

    fs.replace_file(shadow_path, new_shadow_data)
开发者ID:ameade,项目名称:nova,代码行数:35,代码来源:api.py


示例14: change_admin_password

    def change_admin_password(self, password):
        root_logger.debug("Changing admin password")
        dirname = config_dirname(self.serverid)
        dmpwdfile = ""
        admpwdfile = ""

        try:
            (dmpwdfd, dmpwdfile) = tempfile.mkstemp(dir='/var/lib/ipa')
            os.write(dmpwdfd, self.dm_password)
            os.close(dmpwdfd)

            (admpwdfd, admpwdfile) = tempfile.mkstemp(dir='/var/lib/ipa')
            os.write(admpwdfd, password)
            os.close(admpwdfd)

            args = ["/usr/bin/ldappasswd", "-h", self.fqdn,
                    "-ZZ", "-x", "-D", str(DN(('cn', 'Directory Manager'))),
                    "-y", dmpwdfile, "-T", admpwdfile,
                    str(DN(('uid', 'admin'), ('cn', 'users'), ('cn', 'accounts'), self.suffix))]
            try:
                env = { 'LDAPTLS_CACERTDIR':os.path.dirname(CACERT),
                        'LDAPTLS_CACERT':CACERT }
                ipautil.run(args, env=env)
                root_logger.debug("ldappasswd done")
            except ipautil.CalledProcessError, e:
                print "Unable to set admin password", e
                root_logger.debug("Unable to set admin password %s" % e)

        finally:
            if os.path.isfile(dmpwdfile):
                os.remove(dmpwdfile)
            if os.path.isfile(admpwdfile):
                os.remove(admpwdfile)
开发者ID:cajunken,项目名称:freeipa,代码行数:33,代码来源:dsinstance.py


示例15: testParseMaincfg

    def testParseMaincfg(self):
        """ Test parsing of different broker_module declarations """
        path = "/var/lib/nagios/rw/livestatus"  # Path to the livestatus socket

        # Test plain setup with no weird arguments
        fd, filename = tempfile.mkstemp()
        os.write(fd, 'broker_module=./livestatus.o /var/lib/nagios/rw/livestatus')
        status = pynag.Parsers.mk_livestatus(nagios_cfg_file=filename)
        self.assertEqual(path, status.livestatus_socket_path)
        os.close(fd)

        # Test what happens if arguments are provided
        fd, filename = tempfile.mkstemp()
        os.write(fd, 'broker_module=./livestatus.o /var/lib/nagios/rw/livestatus hostgroups=t')
        status = pynag.Parsers.mk_livestatus(nagios_cfg_file=filename)
        self.assertEqual(path, status.livestatus_socket_path)
        os.close(fd)

        # Test what happens if arguments are provided before and after file socket path
        fd, filename = tempfile.mkstemp()
        os.write(fd, 'broker_module=./livestatus.o  num_client_threads=20 /var/lib/nagios/rw/livestatus hostgroups=t')
        status = pynag.Parsers.mk_livestatus(nagios_cfg_file=filename)
        self.assertEqual(path, status.livestatus_socket_path)
        os.close(fd)

        # Test what happens if livestatus socket path cannot be found
        try:
            fd, filename = tempfile.mkstemp()
            os.write(fd, 'broker_module=./livestatus.o  num_client_threads=20')
            status = pynag.Parsers.mk_livestatus(nagios_cfg_file=filename)
            self.assertEqual(path, status.livestatus_socket_path)
            os.close(fd)
            self.assertEqual(True, "Above could should have raised exception")
        except pynag.Parsers.ParserError:
            pass
开发者ID:MirrorZ,项目名称:pynag,代码行数:35,代码来源:test_parsers.py


示例16: process_delta

def process_delta(data, delta):
    if not delta.specific.delta:
        return data
    if delta.specific.delta == 'cat':
        datalines = data.split('\n')
        for line in delta.data.split('\n'):
            if not line:
                continue
            if line[0] == '+':
                datalines.append(line[1:])
            elif line[0] == '-':
                if line[1:] in datalines:
                    datalines.remove(line[1:])
        return "\n".join(datalines)
    elif delta.specific.delta == 'diff':
        basehandle, basename = tempfile.mkstemp()
        basefile = open(basename, 'w')
        basefile.write(data)
        basefile.close()
        os.close(basehandle)
        dhandle, dname = tempfile.mkstemp()
        dfile = open(dname, 'w')
        dfile.write(delta.data)
        dfile.close()
        os.close(dhandle)
        ret = os.system("patch -uf %s < %s > /dev/null 2>&1" \
                        % (basefile.name, dfile.name))
        output = open(basefile.name, 'r').read()
        [os.unlink(fname) for fname in [basefile.name, dfile.name]]
        if ret >> 8 != 0:
            raise Bcfg2.Server.Plugin.PluginExecutionError, ('delta', delta)
        return output
开发者ID:asaf-oh,项目名称:bcfg2,代码行数:32,代码来源:Cfg.py


示例17: test_simple

    def test_simple(self):
        outstream = BytesIO()
        errstream = BytesIO()

        # create a file for initial commit
        handle, fullpath = tempfile.mkstemp(dir=self.repo.path)
        filename = os.path.basename(fullpath)
        porcelain.add(repo=self.repo.path, paths=filename)
        porcelain.commit(repo=self.repo.path, message='test',
                         author='test', committer='test')

        # Setup target repo
        target_path = tempfile.mkdtemp()
        porcelain.clone(self.repo.path, target=target_path, outstream=outstream)

        # create a second file to be pushed
        handle, fullpath = tempfile.mkstemp(dir=self.repo.path)
        filename = os.path.basename(fullpath)
        porcelain.add(repo=self.repo.path, paths=filename)
        porcelain.commit(repo=self.repo.path, message='test2',
            author='test2', committer='test2')

        # Pull changes into the cloned repo
        porcelain.pull(target_path, self.repo.path, 'refs/heads/master',
            outstream=outstream, errstream=errstream)

        # Check the target repo for pushed changes
        r = Repo(target_path)
        self.assertEqual(r['HEAD'].id, self.repo['HEAD'].id)
开发者ID:briarfox,项目名称:dulwich,代码行数:29,代码来源:test_porcelain.py


示例18: wnominate

def wnominate(state, session, chamber, polarity, r_bin="R",
              out_file=None):
    (fd, filename) = tempfile.mkstemp('.csv')
    with os.fdopen(fd, 'w') as out:
        vote_csv(state, session, chamber, out)

    if not out_file:
        (result_fd, out_file) = tempfile.mkstemp('.csv')
        os.close(result_fd)

    r_src_path = os.path.join(os.path.dirname(__file__), 'calc_wnominate.R')

    with open('/dev/null', 'w') as devnull:
        subprocess.check_call([r_bin, "-f", r_src_path, "--args",
                               filename, out_file, polarity],
                              stdout=devnull, stderr=devnull)

    results = {}
    with open(out_file) as f:
        c = csv.DictReader(f)
        for row in c:
            try:
                res = float(row['coord1D'])
            except ValueError:
                res = None
            results[row['leg_id']] = res

    os.remove(filename)

    return results
开发者ID:PamelaM,项目名称:billy,代码行数:30,代码来源:wnominate.py


示例19: chunk_scaffolds

def chunk_scaffolds(target, size):
    chromos = []
    # split target file into `options.size` (~10 Mbp) chunks
    temp_fd, temp_out = tempfile.mkstemp(suffix='.fasta')
    os.close(temp_fd)
    temp_out_handle = open(temp_out, 'w')
    tb = bx.seq.twobit.TwoBitFile(file(target))
    sequence_length = 0
    tb_key_len = len(tb.keys()) - 1
    print '\nRunning against {}'.format(os.path.basename(target))
    print 'Running with the --huge option.  Chunking files into {0} bp...'.format(size)
    for sequence_count, seq in enumerate(tb.keys()):
        sequence = tb[seq][0:]
        sequence_length += len(sequence)
        # write it to the outfile
        temp_out_handle.write('>{0}\n{1}\n'.format(seq, sequence))
        if sequence_length > size:
            temp_out_handle.close()
            # put tempfile name on stack
            chromos.append(temp_out)
            # open a new temp file
            temp_fd, temp_out = tempfile.mkstemp(suffix='.fasta')
            os.close(temp_fd)
            temp_out_handle = open(temp_out, 'w')
            # reset sequence length
            sequence_length = 0
        # if we hit the end of the twobit file
        elif sequence_count >= tb_key_len:
	    temp_out_handle.close()
            # put tempfile name on stack
            chromos.append(temp_out)
    return chromos
开发者ID:TheCulliganMan,项目名称:phyluce,代码行数:32,代码来源:many_lastz.py


示例20: setUp

    def setUp(self):
        self.tmpdir = tempfile.mkdtemp()
        self.rest_service_log = tempfile.mkstemp()[1]
        self.securest_log_file = tempfile.mkstemp()[1]
        self.file_server = FileServer(self.tmpdir)
        self.addCleanup(self.cleanup)
        self.file_server.start()
        storage_manager.storage_manager_module_name = \
            STORAGE_MANAGER_MODULE_NAME

        # workaround for setting the rest service log path, since it's
        # needed when 'server' module is imported.
        # right after the import the log path is set normally like the rest
        # of the variables (used in the reset_state)
        tmp_conf_file = tempfile.mkstemp()[1]
        json.dump({'rest_service_log_path': self.rest_service_log,
                   'rest_service_log_file_size_MB': 1,
                   'rest_service_log_files_backup_count': 1,
                   'rest_service_log_level': 'DEBUG'},
                  open(tmp_conf_file, 'w'))
        os.environ['MANAGER_REST_CONFIG_PATH'] = tmp_conf_file
        try:
            from manager_rest import server
        finally:
            del(os.environ['MANAGER_REST_CONFIG_PATH'])

        server.reset_state(self.create_configuration())
        utils.copy_resources(config.instance().file_server_root)
        server.setup_app()
        server.app.config['Testing'] = True
        self.app = server.app.test_client()
        self.client = self.create_client()
        self.initialize_provider_context()
开发者ID:pkdevboxy,项目名称:cloudify-manager,代码行数:33,代码来源:base_test.py



注:本文中的tempfile.mkstemp函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tempfile.mktemp函数代码示例发布时间:2022-05-27
下一篇:
Python tempfile.mkdtemp函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap