shell.py 文件源码

python
阅读 36 收藏 0 点赞 0 评论 0

项目:deb-python-rjsmin 作者: openstack 项目源码 文件源码
def mkstemp(suffix="", prefix=_tempfile.gettempprefix(), dir=None,
                text=False):
        """ Create secure temp file """
        # pylint: disable = W0622
        if dir is None:
            dir = _tempfile.gettempdir()
        if text:
            flags = _text_openflags
        else:
            flags = _bin_openflags
        count = 100
        while count > 0:
            j = _tempfile._counter.get_next() # pylint: disable = E1101, W0212
            fname = _os.path.join(dir, prefix + str(j) + suffix)
            try:
                fd = _os.open(fname, flags, 0600)
            except OSError, e:
                if e.errno == _errno.EEXIST:
                    count -= 1
                    continue
                raise
            _set_cloexec(fd)
            return fd, _os.path.abspath(fname)
        raise IOError, (_errno.EEXIST, "No usable temporary file name found")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号