我们从Python开源项目中,提取了以下13个代码示例,用于说明如何使用errno.E2BIG。
def _test_env_var_size(): # max seems to be 1024 * 127 """Private function to verify the maximum command line payload size. This should be smatter and bisect, but it doesn't """ for f in range(256, 100, -1): payload = 'a' * 1024 * f try: cmd = ["ssh", "-t"] + sys.argv[1:] +\ ["wc -c <<<'{}' ; sleep 0.2 ; exit".format(payload)] if call(cmd) == 0: print("%s is good" % f) print(len(payload)) break except OSError as e: if e.errno == errno.E2BIG: pass
def __init__(self, code=None, msg='Unknown error'): super(XAttrMetadataError, self).__init__(msg) self.code = code # Parsing code and msg if (self.code in (errno.ENOSPC, errno.EDQUOT) or 'No space left' in self.msg or 'Disk quota excedded' in self.msg): self.reason = 'NO_SPACE' elif self.code == errno.E2BIG or 'Argument list too long' in self.msg: self.reason = 'VALUE_TOO_LONG' else: self.reason = 'NOT_SUPPORTED'
def __init__(self, code=None, msg='Unknown error'): super(XAttrMetadataError, self).__init__(msg) self.code = code self.msg = msg # Parsing code and msg if (self.code in (errno.ENOSPC, errno.EDQUOT) or 'No space left' in self.msg or 'Disk quota excedded' in self.msg): self.reason = 'NO_SPACE' elif self.code == errno.E2BIG or 'Argument list too long' in self.msg: self.reason = 'VALUE_TOO_LONG' else: self.reason = 'NOT_SUPPORTED'
def test_non_retryable_error(self, m_select): m_select.side_effect = iter([ ([self.sck], [], []), ]) err = socket.error() err.errno = errno.E2BIG self.sck.recv.side_effect = err msg_gen = self.reader.new_messages(timeout=1) self.assertRaises(socket.error, next, msg_gen)
def test_maas_meta_last_modified_reraises_non_ENOENT(self): path = factory.make_file(self.tftproot, name="maas.meta") oserror = OSError() oserror.errno = errno.E2BIG self.patch(os.path, 'getmtime').side_effect = oserror self.assertRaises(OSError, maas_meta_last_modified, path)