Skip to content

Instantly share code, notes, and snippets.

@Piker-Alpha
Created October 18, 2017 13:24
Show Gist options
  • Save Piker-Alpha/c811dd2a1300c56de7998ec5d96ac95a to your computer and use it in GitHub Desktop.
Save Piker-Alpha/c811dd2a1300c56de7998ec5d96ac95a 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