Created
March 28, 2019 21:01
-
-
Save AndrewWCarson/8b3e46d70580f106d75ba2e4154320af to your computer and use it in GitHub Desktop.
Uses pyobjc and IOKit to check for the BootDriveIsInternalSolidState value.
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 | |
# Based on some nice gists by Mike Lynn (@pudquick) | |
import objc | |
from CoreFoundation import NSBundle | |
IOKit_bundle = NSBundle.bundleWithIdentifier_('com.apple.framework.IOKit') | |
functions = [("IOServiceGetMatchingService", b"II@"), | |
("IOServiceMatching", b"@*"), | |
("IORegistryEntryCreateCFProperty", b"@I@@I"), | |
] | |
objc.loadBundleFunctions(IOKit_bundle, globals(), functions) | |
def is_SSD(): | |
x86Platform = IOServiceGetMatchingService(0, IOServiceMatching("X86PlatformPlugin")) | |
return IORegistryEntryCreateCFProperty(x86Platform, 'BootDriveIsInternalSolidState'.encode("utf-8"), None, 0) | |
if __name__ == '__main__': | |
if is_SSD(): | |
print "true" | |
else: | |
print "false" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The "true" & "false" output from the main function is just a convention that works well with boolean Custom Facts in Addigy.