forked from erikberglund/AppBlocker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplist_binary.py
52 lines (46 loc) · 1.75 KB
/
plist_binary.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
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
### Binary Plist checker
import subprocess
import json
applicationDB = {}
apps = [
"/Applications/Utilities/Adobe Flash Player Install Manager.app",
"/Users/os/Desktop/Apps/iMovie.app",
"/Applications/iTunes.app",
"/Applications/Microsoft Word.app",
"/Applications/Microsoft Outlook.app",
"/Applications/GarageBand.app",
"/Applications/Microsoft Excel.app",
"/Applications/Microsoft PowerPoint.app",
"/Applications/Microsoft OneNote.app",
"/Applications/Adobe InDesign CS6/Adobe InDesign CS6.app",
"/Library/Application Support/Microsoft/MAU2.0/Microsoft AutoUpdate.app",
"/Applications/Game Maker Lite.app"
]
def getBinaryPlistKey(plist, key):
process = subprocess.Popen(['defaults', 'read', plist, key], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
output = process.stdout.readline()
if process.poll() is None:
return output.strip()
else:
return None
addtionalKeys = {
"CFBundleDisplayName": "appName",
"CFBundleName": "someName",
"CFBundleExecutable": "executableName",
"CFBundleShortVersionString": "appVersion",
"LSApplicationCategoryType": "category",
"INVALID": "INVALID"
}
for app in apps:
plist = '/'.join([app, 'Contents/Info.plist'])
bundleID = getBinaryPlistKey(plist, 'CFBundleIdentifier')
if bundleID != None:
##appsWithErrors['binaryPlist'].remove(app)
applicationDB[bundleID] = {}
applicationDB[bundleID]['appPath'] = app
for key in addtionalKeys.keys():
value = getBinaryPlistKey(plist, key)
if value != None:
applicationDB[bundleID][addtionalKeys[key]] = value
print json.dumps(applicationDB, indent=4, sort_keys=True)