当前位置: 首页>>代码示例>>Python>>正文


Python SpooledTemporaryFile.__init__方法代码示例

本文整理汇总了Python中tempfile.SpooledTemporaryFile.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python SpooledTemporaryFile.__init__方法的具体用法?Python SpooledTemporaryFile.__init__怎么用?Python SpooledTemporaryFile.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tempfile.SpooledTemporaryFile的用法示例。


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

示例1: __init__

# 需要导入模块: from tempfile import SpooledTemporaryFile [as 别名]
# 或者: from tempfile.SpooledTemporaryFile import __init__ [as 别名]
 def __init__(self, path, filename, fs, max_size=WRITE_BUFFER_SIZE):
     """We need the path so we can write the buffered file to the API"""
     SpooledTemporaryFile.__init__(self, max_size=max_size)  # old-style!
     self.path = path
     self.filename = filename
     self.fs = fs
     self.fullpath = ''
     try:
         self.fullpath = self.create_file()
     except RequestError, e:
         SpooledTemporaryFile.close(self)
         raise FilesystemError(str(e))
开发者ID:Qumulo,项目名称:qftpd,代码行数:14,代码来源:qftpd.py

示例2: __init__

# 需要导入模块: from tempfile import SpooledTemporaryFile [as 别名]
# 或者: from tempfile.SpooledTemporaryFile import __init__ [as 别名]
    def __init__(self, filepath, mode='rtc'):
        """filepath: the path of the distant file
           mode: take the same argument as mode argument of the global
                 open() + optional flag c (which mean store in cache).
        """

        self.mode = mode
        self.filepath = filepath
        host, port = utils.get_host_port(_config['nameserver'])
        self.srv = utils.get_server(filepath, host, port)

        if self.srv is None:
            raise DFSIOError('Impossible to find a server that serve %s.'
                    % filepath)

        self.last_modified = None
        SpooledTemporaryFile.__init__(self, _config['max_size'], mode.replace('c', ''))

        host, port = utils.get_host_port(_config['lockserver'])
        if utils.is_locked(filepath, host, port):
            raise DFSIOError('The file %s is locked.' % filepath)

        if 'w' not in mode:
            host, port = utils.get_host_port(self.srv)
            with closing(HTTPConnection(host, port)) as con:
                con.request('GET', filepath)
                response = con.getresponse()
                self.last_modified = response.getheader('Last-Modified')
                status = response.status

                if status not in (200, 204):
                    raise DFSIOError('Error (%d) while opening file.' % status)

                if status != 204:
                    self.write(response.read())

                if 'r' in mode:
                    self.seek(0)

                self.lock_id = None

        if 'a' in mode or 'w' in mode:
            # automatically gets a lock if we're in write/append mode
            host, port = utils.get_host_port(_config['lockserver'])
            self.lock_id = int(utils.get_lock(filepath, host, port))

        if 'c' in mode:
            File._cache[filepath] = self
开发者ID:Alexis-D,项目名称:DFS,代码行数:50,代码来源:client.py

示例3: __init__

# 需要导入模块: from tempfile import SpooledTemporaryFile [as 别名]
# 或者: from tempfile.SpooledTemporaryFile import __init__ [as 别名]
 def __init__(self, file_obj, max_size=50*1024*1024):
     self._file_obj = file_obj
     SpooledTemporaryFile.__init__(self, max_size)
开发者ID:JimmXinu,项目名称:calibre,代码行数:5,代码来源:save.py

示例4: __init__

# 需要导入模块: from tempfile import SpooledTemporaryFile [as 别名]
# 或者: from tempfile.SpooledTemporaryFile import __init__ [as 别名]
 def __init__(self, threshold=10 * 1024 * 1024, **kw):
     # STF uses >, the old ATF used >= for the max_size check
     SpooledTemporaryFile.__init__(self, max_size=threshold - 1, **kw)
开发者ID:mamico,项目名称:relstorage,代码行数:5,代码来源:autotemp.py


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