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


Python errno.EFBIG属性代码示例

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


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

示例1: test_rlimit

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EFBIG [as 别名]
def test_rlimit(self):
        p = psutil.Process()
        soft, hard = p.rlimit(psutil.RLIMIT_FSIZE)
        try:
            p.rlimit(psutil.RLIMIT_FSIZE, (1024, hard))
            with open(TESTFN, "wb") as f:
                f.write(b"X" * 1024)
            # write() or flush() doesn't always cause the exception
            # but close() will.
            with self.assertRaises(IOError) as exc:
                with open(TESTFN, "wb") as f:
                    f.write(b"X" * 1025)
            self.assertEqual(exc.exception.errno if PY3 else exc.exception[0],
                             errno.EFBIG)
        finally:
            p.rlimit(psutil.RLIMIT_FSIZE, (soft, hard))
            self.assertEqual(p.rlimit(psutil.RLIMIT_FSIZE), (soft, hard)) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:19,代码来源:test_process.py

示例2: test_rlimit

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EFBIG [as 别名]
def test_rlimit(self):
        p = psutil.Process()
        testfn = self.get_testfn()
        soft, hard = p.rlimit(psutil.RLIMIT_FSIZE)
        try:
            p.rlimit(psutil.RLIMIT_FSIZE, (1024, hard))
            with open(testfn, "wb") as f:
                f.write(b"X" * 1024)
            # write() or flush() doesn't always cause the exception
            # but close() will.
            with self.assertRaises(IOError) as exc:
                with open(testfn, "wb") as f:
                    f.write(b"X" * 1025)
            self.assertEqual(exc.exception.errno if PY3 else exc.exception[0],
                             errno.EFBIG)
        finally:
            p.rlimit(psutil.RLIMIT_FSIZE, (soft, hard))
            self.assertEqual(p.rlimit(psutil.RLIMIT_FSIZE), (soft, hard)) 
开发者ID:giampaolo,项目名称:psutil,代码行数:20,代码来源:test_process.py

示例3: test_add_file_too_big

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EFBIG [as 别名]
def test_add_file_too_big(self):
        """
        Tests that adding an excessively large image file
        raises an appropriate exception
        """
        self._do_test_add_write_failure(errno.EFBIG, exceptions.StorageFull) 
开发者ID:openstack,项目名称:glance_store,代码行数:8,代码来源:test_filesystem_store.py

示例4: test_add_file_too_big

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EFBIG [as 别名]
def test_add_file_too_big(self):
        """Tests adding a very large image.

        Tests that adding an excessively large image file
        raises an appropriate exception.
        """
        self._do_test_add_write_failure(errno.EFBIG, exceptions.StorageFull) 
开发者ID:openstack,项目名称:glance_store,代码行数:9,代码来源:test_multistore_filesystem.py

示例5: write

# 需要导入模块: import errno [as 别名]
# 或者: from errno import EFBIG [as 别名]
def write(self, path, buf, offset, fh):
        """
            We don't like big big files, so we need to be really carefull
            with them. First we check for offset, then for size. If any of this
            is off limit, raise EFBIG error and delete the file.
        """

        if offset + len(buf) > self.max_size:
            raise FuseOSError(errno.EFBIG)

        result = super(CurrentView, self).write(path, buf, offset, fh)
        self.dirty[fh] = {"message": "Update {}".format(path), "stage": True}

        log.debug("CurrentView: Wrote %s to %s", len(buf), path)
        return result 
开发者ID:presslabs,项目名称:gitfs,代码行数:17,代码来源:current.py


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