def read(fd, **kwargs):
"""
Reads at most size bytes from the file (less if the read hits EOF before
obtaining size bytes).
:Arguments:
fd - file descriptor got from open_file
:Optional:
size - number of bytes to be read
:Return:
the string read from the file, None if not able to read
"""
try:
readsize = fd.read(**kwargs)
print_info("read {} bytes from file {}".format(readsize, fd.name))
except ValueError:
print_error("file is already closed...")
readsize = 0
except Exception as e:
print_error("found exception {} while reading {}".format(str(e), fd))
readsize = 0
return readsize
评论列表
文章目录