sysstat.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:sarjitsu 作者: distributed-system-analysis 项目源码 文件源码
def verify_contents(thefile, tgt_hostname=None, callback=None):
    """
    Given a sysstat binary data file verify that it contains a set of well
    formed data values.

    The optional 'tgt_hostname' argument is checked against the file header's
    stored hostname value.

    The optional 'callback' argument, if provided, should be an instance of
    the ContentAction class, where for each magic structure, file header, file
    activity set, record header and record payload read the appropriate method
    will be invoked, with the 'eof' method invoked at the end.

    One of the following exceptions will be raised if a problem is found with
    the file:

        Invalid: The file header or record header metadata values do not make
                 sense in relation to each other

        Corruption: The file appears to be corrupted in some way

        Truncated: The file does not appear to contain all the data as
                   described by the file header or a given record header
    """
    try:
        with lzma.open(thefile, "rb") as fp:
            verify_contents_fp(fp, tgt_hostname, callback)
    except lzma.LZMAError:
        with open(thefile, "rb") as fp:
            verify_contents_fp(fp, tgt_hostname, callback)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号