本文整理汇总了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))
示例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))
示例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)
示例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)
示例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