-
Notifications
You must be signed in to change notification settings - Fork 10
/
marketing_model.py
executable file
·40 lines (31 loc) · 1.54 KB
/
marketing_model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/python
#ref: https://gist.github.com/pudquick/098f399d69f230521ef530baca832e76
# Tested on 10.11
# Note:
# The marketing information embedded in the ServerInformation.framework is not the same as what
# About This Mac displays - there are differences.
#
# For example:
# ServerInformation: 15" MacBook Pro with Retina display (Mid 2015)
# About This Mac: MacBook Pro (Retina, 15-inch, Mid 2015)
#
# About This Mac will actually hit the internet API to perform the lookup,
# and then saves it locally for future use.
from Foundation import NSBundle
import xml.etree.ElementTree as ET
import urllib2
ServerInformation = NSBundle.bundleWithPath_('/System/Library/PrivateFrameworks/ServerInformation.framework')
ServerCompatibility = NSBundle.bundleWithPath_('/System/Library/PrivateFrameworks/ServerCompatibility.framework')
ServerInformationComputerModelInfo = ServerInformation.classNamed_('ServerInformationComputerModelInfo')
SVCSystemInfo = ServerCompatibility.classNamed_('SVCSystemInfo')
info = SVCSystemInfo.currentSystemInfo()
extended_info = ServerInformationComputerModelInfo.attributesForModelIdentifier_(info.computerModelIdentifier())
if extended_info:
# We don't have to hit the internet API, we have some marketing knowledge
marketing_name = extended_info['marketingModel']
else:
# Sadly we'll have to reach out
API = urllib2.urlopen('http://support-sp.apple.com/sp/product?cc=' + info.serialNumber()[-4:])
marketing_name = ET.fromstring(API.read()).find('configCode').text
API.close()
print marketing_name