Created
December 21, 2016 03:39
-
-
Save carlashley/927a9fd6b1d03081f311bde017170d3e to your computer and use it in GitHub Desktop.
Mac Hardware Info
This file contains 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 | |
# Use system_profiler output in XML to get information about Mac hardware | |
import plistlib | |
import subprocess | |
cmd = ['system_profiler', '-xml', 'SPHardwareDataType'] | |
(results, error) = subprocess.Popen(cmd, | |
stdout=subprocess.PIPE, | |
stderr=subprocess.PIPE).communicate() | |
hardware = plistlib.readPlistFromString(results)[0]['_items'][0] | |
serial_no = hardware['serial_number'] | |
platform_uuid = hardware['platform_UUID'] | |
machine_model = hardware['machine_model'] | |
print serial_no | |
print platform_uuid | |
print machine_model | |
print 'Available keys: %s' % hardware.keys() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment