is_ssd.py 文件源码

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

项目:unearth 作者: chilcote 项目源码 文件源码
def fact():
    '''Returns whether the boot drive is an ssd'''
    result = 'Unknown'

    try:
        proc = subprocess.Popen(
                ['/usr/sbin/diskutil', 'info', '-plist', '/'],
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE
                )
        stdout, _ = proc.communicate()
    except (IOError, OSError):
        stdout = None

    if stdout:
        d = plistlib.readPlistFromString(stdout.strip())
        if (
            not d.get('CoreStorageCompositeDisk', False) and
            not d.get('RAIDMaster', False)
           ):
            result = d.get('SolidState', False)

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


问题


面经


文章

微信
公众号

扫码关注公众号