本文整理汇总了Python中stat.S_ISFIFO属性的典型用法代码示例。如果您正苦于以下问题:Python stat.S_ISFIFO属性的具体用法?Python stat.S_ISFIFO怎么用?Python stat.S_ISFIFO使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类stat
的用法示例。
在下文中一共展示了stat.S_ISFIFO属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: copyfile
# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_ISFIFO [as 别名]
def copyfile(src, dst):
"""Copy data from src to dst"""
if _samefile(src, dst):
raise Error("`%s` and `%s` are the same file" % (src, dst))
for fn in [src, dst]:
try:
st = os.stat(fn)
except OSError:
# File most likely does not exist
pass
else:
# XXX What about other special files? (sockets, devices...)
if stat.S_ISFIFO(st.st_mode):
raise SpecialFileError("`%s` is a named pipe" % fn)
with open(src, 'rb') as fsrc:
with open(dst, 'wb') as fdst:
copyfileobj(fsrc, fdst)
示例2: __hashEntry
# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_ISFIFO [as 别名]
def __hashEntry(self, prefix, entry, s):
if stat.S_ISREG(s.st_mode):
digest = self.__index.check(prefix, entry, s, hashFile)
elif stat.S_ISDIR(s.st_mode):
digest = self.__hashDir(prefix, entry)
elif stat.S_ISLNK(s.st_mode):
digest = self.__index.check(prefix, entry, s, DirHasher.__hashLink)
elif stat.S_ISBLK(s.st_mode) or stat.S_ISCHR(s.st_mode):
digest = struct.pack("<L", s.st_rdev)
elif stat.S_ISFIFO(s.st_mode):
digest = b''
else:
digest = b''
logging.getLogger(__name__).warning("Unknown file: %s", entry)
return digest
示例3: mode_filetype
# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_ISFIFO [as 别名]
def mode_filetype(mode):
mode = stat.S_IFMT(mode)
dic = {
stat.S_ISFIFO: "fifo file",
stat.S_ISCHR: "character device",
stat.S_ISDIR: "directory",
stat.S_ISBLK: "block device",
stat.S_ISREG: "regular file",
stat.S_ISLNK: "symbolic link",
stat.S_ISSOCK: "socket",
stat.S_ISDOOR: "door",
}
for test_func, name in dic.items():
if test_func(mode):
return name
return "???"
示例4: check_fileaccessible
# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_ISFIFO [as 别名]
def check_fileaccessible(this_path):
'''
检查文件是否可以访问
:parm
file:需要检查的文件,支持当前相对路径、~、或者绝对路径
:return
返回一个(执行结果代码,原因)
执行结果代码:Flase失败,True成功
原因:成功为True,失败为失败原因
'''
result = path_isexists(this_path)
if result[0] :
this_path = result[1]
else :
return result
if not os.path.isfile(this_path) :
return (False, '路径存在,但不是一个文件')
if not (os.path.isfile(this_path) or stat.S_ISFIFO(os.stat(this_path).st_mode)):
return (False, "该文件没有权限访问")
return (True, this_path)
示例5: compress
# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_ISFIFO [as 别名]
def compress(self, files_to_compress=None):
"""
Compress the output files of a job object.
Args:
files_to_compress (list): A list of files to compress (optional)
"""
# delete empty files
if files_to_compress is None:
files_to_compress = [
f for f in list(self.list_files())
if (f not in ["rho.sxb", "waves.sxb"]
and not stat.S_ISFIFO(os.stat(os.path.join(
self.working_directory, f
)).st_mode))
]
for f in list(self.list_files()):
filename = os.path.join(self.working_directory, f)
if (
f not in files_to_compress
and os.path.exists(filename)
and os.stat(filename).st_size == 0
):
os.remove(filename)
super(SphinxBase, self).compress(files_to_compress=files_to_compress)
示例6: _stdin_is_tty
# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_ISFIFO [as 别名]
def _stdin_is_tty(self):
"""Detect whether the stdin is mapped to a terminal console.
I found this technique in the answer by thg435 here:
http://stackoverflow.com/questions/13442574/how-do-i-determine-if-sys-stdin-is-redirected-from-a-file-vs-piped-from-another
"""
import os
import stat
mode = os.fstat(0).st_mode
if ((not stat.S_ISFIFO(mode)) and # piped
(not stat.S_ISREG(mode))): # redirected
return True
else:
# not piped or redirected, so assume terminal input
return False
示例7: __init__
# 需要导入模块: import stat [as 别名]
# 或者: from stat import S_ISFIFO [as 别名]
def __init__(self, loop, pipe, protocol, waiter=None, extra=None):
super().__init__(extra)
self._extra['pipe'] = pipe
self._loop = loop
self._pipe = pipe
self._fileno = pipe.fileno()
mode = os.fstat(self._fileno).st_mode
if not (stat.S_ISFIFO(mode) or
stat.S_ISSOCK(mode) or
stat.S_ISCHR(mode)):
raise ValueError("Pipe transport is for pipes/sockets only.")
_set_nonblocking(self._fileno)
self._protocol = protocol
self._closing = False
self._loop.call_soon(self._protocol.connection_made, self)
# only start reading when connection_made() has been called
self._loop.call_soon(self._loop.add_reader,
self._fileno, self._read_ready)
if waiter is not None:
# only wake up the waiter when connection_made() has been called
self._loop.call_soon(futures._set_result_unless_cancelled,
waiter, None)