Created
November 8, 2017 14:50
-
-
Save scriptingosx/8f0f83dd42e7d5cd6287eef5a9ae7c71 to your computer and use it in GitHub Desktop.
Get the localized "Marketing Name" for a Mac
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 | |
import sys | |
import plistlib | |
import subprocess | |
from Cocoa import NSBundle | |
if (len(sys.argv) == 2): | |
model = sys.argv[1] | |
else: | |
model = subprocess.check_output(["/usr/sbin/sysctl", "-n", "hw.model"]).strip() | |
serverInfoBundle=NSBundle.bundleWithPath_("/System/Library/PrivateFrameworks/ServerInformation.framework/") | |
sysinfofile=serverInfoBundle.URLForResource_withExtension_subdirectory_("SIMachineAttributes", "plist", "") | |
plist = plistlib.readPlist(sysinfofile.path()) | |
if (model in plist): | |
print plist[model]["_LOCALIZABLE_"]["marketingModel"] | |
else: | |
print "%s not found" % (model) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment