Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Get the localized "Marketing Name" for a Mac
#!/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