Created
September 11, 2018 05:19
-
-
Save codeOfRobin/de5ac303a2e2f96e95ef02c729c2633c to your computer and use it in GitHub Desktop.
Tiny script to get the "marketing name" of your π₯/π»
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 | |
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