Created
December 22, 2016 01:03
-
-
Save carlashley/edcfe6954b6df5f47a882026df112b38 to your computer and use it in GitHub Desktop.
Disk information in macOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# Function returns a dict containing the results of `diskutil info /dev/disk` | |
import plistlib | |
import subprocess | |
def disk_info(disk): | |
cmd = ['/usr/sbin/diskutil', 'info', '-plist', disk] | |
(results, error) = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate() | |
if results: | |
return plistlib.readPlistFromString(results) | |
else: | |
return error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment