本文整理汇总了Python中errno.ESPIPE属性的典型用法代码示例。如果您正苦于以下问题:Python errno.ESPIPE属性的具体用法?Python errno.ESPIPE怎么用?Python errno.ESPIPE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类errno
的用法示例。
在下文中一共展示了errno.ESPIPE属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ESPIPE [as 别名]
def __init__(self, input, size=None, **args):
if not hasattr(input, "seek"):
if size is None:
input = InputPipe(input, self._setSize)
else:
input = InputPipe(input)
elif size is None:
try:
input.seek(0, 2)
size = input.tell() * 8
except IOError, err:
if err.errno == ESPIPE:
input = InputPipe(input, self._setSize)
else:
charset = getTerminalCharset()
errmsg = unicode(str(err), charset)
source = args.get("source", "<inputio:%r>" % input)
raise InputStreamError(_("Unable to get size of %s: %s") % (source, errmsg))
示例2: exit_cleanly
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ESPIPE [as 别名]
def exit_cleanly(errnum=None):
"""exit_cleanly
Exits the runtime cleanly using SystemExit. This is the official, handling
exception here as this is mostly meant to be a standalone script.
"""
default = "An Unknown Error has Occurred!"
cases = {errno.EINVAL: "Improper or invalid input value",
errno.ESPIPE: "Could not complete action due to a broken" +
" dependency",
errno.ENOSYS: "Could not complete action due to unexpected setup",
errno.EIO: "Could not access an expected file",
errno.EPERM: "Could not access an item due to permissions issues",
-1: default}
help_stmt = """
%s [--opt [option]]
With opts:
working_directory - ONLY use this if you're overwriting `pwd`!
""" % (sys.argv[0])
if not errnum:
errnum = 0
elif not isinstance(errnum, int) and hasattr(errno, errnum):
errnum = getattr(errno, errnum)
try:
errnum = int(errnum)
except TypeError:
errnum = -1
if errnum == 0:
help_stmt = ''
stmt = "Successful in configuration!"
elif errnum in cases:
stmt = cases[errnum]
else:
stmt = default
print("%s\n\n%s" % (stmt, help_stmt))
示例3: try_seek
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ESPIPE [as 别名]
def try_seek(fd, offset):
try:
if offset is None:
os.lseek(fd, 0, os.SEEK_END)
elif offset >= 0:
os.lseek(fd, offset, os.SEEK_SET)
else:
os.lseek(fd, offset, os.SEEK_END)
except OSError as ose:
if ose.args[0] != errno.ESPIPE:
raise
示例4: get_file_size
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ESPIPE [as 别名]
def get_file_size(file_obj):
if (hasattr(file_obj, 'seek') and hasattr(file_obj, 'tell') and
(six.PY2 or six.PY3 and file_obj.seekable())):
try:
curr = file_obj.tell()
file_obj.seek(0, os.SEEK_END)
size = file_obj.tell()
file_obj.seek(curr)
return size
except IOError as e:
if e.errno == errno.ESPIPE:
return
else:
raise
示例5: seek
# 需要导入模块: import errno [as 别名]
# 或者: from errno import ESPIPE [as 别名]
def seek(self, offset: int, whence: int = os.SEEK_SET):
raise FdError("Invalid write() operation on SocketDesc", errno.ESPIPE) # EINVAL? EBADF?