xprotect_date.py 文件源码

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

项目:unearth 作者: chilcote 项目源码 文件源码
def fact():
    '''Returns the last date xprotect was updated'''

    result = 'None'

    try:
        cmd = ['/usr/sbin/pkgutil', '--pkgs=.*XProtect.*']
        proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        (pkgs, stderr) = proc.communicate()

        if pkgs:
            dates = []
            for pkgid in pkgs.splitlines():
                pkginfo_plist = subprocess.check_output(['/usr/sbin/pkgutil',
                                                        '--pkg-info-plist',
                                                        pkgid])
                pkginfo = plistlib.readPlistFromString(pkginfo_plist)
                dates.append(pkginfo['install-time'])

            result = time.strftime('%Y-%m-%dT%H:%M:%S', time.localtime(max(dates)))
    except (OSError, IOError):
        pass

    return {factoid: result}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号