Forked from Piker-Alpha/unenrollFromSeedingProgram.py
Created
April 17, 2018 20:47
-
-
Save jhbush/f5d7f25c46d371ccfdb9a1d131fffbca 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