Created
October 18, 2017 13:24
-
-
Save Piker-Alpha/c811dd2a1300c56de7998ec5d96ac95a to your computer and use it in GitHub Desktop.
Python implementation of: seedutil unenroll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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