Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# Written in 10 minutes and tested on 10.10.2 only. Use with caution.
import subprocess
import plistlib
import os
from Foundation import CFPreferencesCopyAppValue
def boot_rom_version():
cmd = ['/usr/sbin/system_profiler','-xml','SPHardwareDataType']
task = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdout, stderr) = task.communicate()
data = plistlib.readPlistFromString(stdout)
boot_rom_version = data[0]['_items'][0]['boot_rom_version']
return boot_rom_version
def write_conditional():
BUNDLE_ID = 'ManagedInstalls'
pref_name = 'ManagedInstallDir'
managedinstalldir = CFPreferencesCopyAppValue(pref_name, BUNDLE_ID)
conditionalitemspath = os.path.join(managedinstalldir, 'ConditionalItems.plist')
if os.path.exists(conditionalitemspath):
data_dict = plistlib.readPlist(conditionalitemspath)
data_dict = {}
version = boot_rom_version()
data_dict['boot_rom_version'] = version
plistlib.writePlist(data_dict, conditionalitemspath)
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment