Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jhbush/f5d7f25c46d371ccfdb9a1d131fffbca to your computer and use it in GitHub Desktop.
Save jhbush/f5d7f25c46d371ccfdb9a1d131fffbca to your computer and use it in GitHub Desktop.
Python implementation of: seedutil unenroll
#!/usr/bin/python
''' Python implementation of "seedutil unenroll" '''
import os
import objc
from Foundation import NSBundle, NSClassFromString
SeedingBundle = NSBundle.bundleWithPath_('/System/Library/PrivateFrameworks/Seeding.framework')
functions = [
('isEnrolledInSeedProgram', '@I'),
('_stringForSeedProgram_', '@I'),
('currentSeedProgram', '@'),
('_setSeedProgramPref', '@I'),
('_clearSeedCatalog', '@'),
('_setHelpFeedbackMenuEnabled', '@I'),
('_setSeedOptOutUIDisabled', '@I'),
]
constants = [
('kSeedEnrollmentCookiePath', '@'),
]
objc.loadBundleFunctions(SeedingBundle, globals(), functions)
objc.loadBundleVariables(SeedingBundle, globals(), constants)
seedProgramManager = NSClassFromString('SDSeedProgramManager')
if seedProgramManager.isEnrolledInSeedProgram() != 0:
print "Seeding: Un-enrolling from seed program: %s" % seedProgramManager._stringForSeedProgram_(seedProgramManager.currentSeedProgram())
seedProgramManager._setSeedProgramPref_(0)
seedProgramManager._clearSeedCatalog()
seedProgramManager._setHelpFeedbackMenuEnabled_(0)
seedProgramManager._setSeedOptOutUIDisabled_(0)
if os.path.exists(kSeedEnrollmentCookiePath):
print "Seeding: Removing enrollment cookie"
try:
os.remove(kSeedEnrollmentCookiePath)
except IOError, err:
print "Seeding: Error removing enrollment cookie: %s" % err
else:
print "Seeding: Not currently enrolled in any seed program, skipping un-enrollment"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment