Skip to content

Instantly share code, notes, and snippets.

@scriptingosx
Created November 8, 2017 14:50
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save scriptingosx/8f0f83dd42e7d5cd6287eef5a9ae7c71 to your computer and use it in GitHub Desktop.
Save scriptingosx/8f0f83dd42e7d5cd6287eef5a9ae7c71 to your computer and use it in GitHub Desktop.
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