Python Foundation.CFPreferencesCopyAppValue() Examples
The following are 6
code examples of Foundation.CFPreferencesCopyAppValue().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
Foundation
, or try the search function
.
Example #1
Source File: macos_prefs.py From ants with GNU General Public License v3.0 | 6 votes |
def read_prefs(prefs_section): """Read indicated preferences section and return a dict. Uses CFPreferencesCopyAppValue. Preferences can be defined several places. Precedence is: - MCX/configuration profile - /var/root/Library/Preferences/[BUNDLE_ID].plist - /Library/Preferences/[BUNDLE_ID].plist - .GlobalPreferences defined at various levels (ByHost, user, system) """ macos_dict = CFPreferencesCopyAppValue(prefs_section, BUNDLE_ID) if macos_dict is None: macos_dict = {} else: macos_dict = convert_dict(macos_dict) return macos_dict
Example #2
Source File: CreativeCloudPackager.py From adobe-ccp-recipes with Apache License 2.0 | 6 votes |
def check_and_disable_appnap_for_pdapp(self): """Log a warning if AppNap isn't disabled on the system.""" appnap_disabled = CFPreferencesCopyAppValue( 'NSAppSleepDisabled', 'com.adobe.PDApp') if not appnap_disabled: self.output("WARNING: A bug in Creative Cloud Packager makes " "it likely to stall indefinitely whenever the app " "window is hidden or obscured due to App Nap. To " "prevent this, we're setting a user preference to " "disable App Nap for just the " "Adobe PDApp application. This can be undone using " "this command: 'defaults delete com.adobe.PDApp " "NSAppSleepDisabled") CFPreferencesSetAppValue( 'NSAppSleepDisabled', True, 'com.adobe.PDApp')
Example #3
Source File: mac_prefs.py From salt-osx with MIT License | 5 votes |
def _read_pref(name, domain, user, host, runas): ''' helper function for reading the preference, either at the user level or system level ''' if runas: try: # convert to uid for later use. uid = pwd.getpwnam(runas).pw_uid except KeyError: raise CommandExecutionError( 'Set to runas user {}, this user' ' does not exist.'.format(runas) ) # need to run as the user log.debug('Setting EUID to {}'.format(runas)) os.seteuid(uid) if user: user_domain, host_domain = _get_user_and_host(user, host) log.debug('Reading key: "{}" in domain: "{}"'.format(name, domain)) value = Foundation.CFPreferencesCopyValue(name, domain, user_domain, host_domain) os.seteuid(0) return value #need to bring ourselves back up to root path = '/var/root/Library/Preferences/' d_path = os.path.join(path, domain) log.debug('Reading key: "{}" in domain: "{}" at "{}"'.format(name, domain, d_path)) return Foundation.CFPreferencesCopyAppValue(name, domain)
Example #4
Source File: run_once.py From zentral with Apache License 2.0 | 5 votes |
def get_monolith_auth_header(): for header in CFPreferencesCopyAppValue(MONOLITH_HEADERS_PREF_KEY, MUNKI_APPLICATION_ID): if header.startswith(MONOLITH_TOKEN_HEADER_KEY): return MONOLITH_TOKEN_HEADER_KEY, header.split(":", 1)[-1].strip() print "Could not get the monolith token"
Example #5
Source File: ard_info.py From sal with Apache License 2.0 | 5 votes |
def main(): bundle_id = "com.apple.RemoteDesktop.plist" sal_key = "ARD_Info_{}" prefs_key_prefix = "Text{}" data = { sal_key.format(i): CFPreferencesCopyAppValue(prefs_key_prefix.format(i), bundle_id) or "" for i in range(1, 5)} sal.add_plugin_results('ARD_Info', data)
Example #6
Source File: firewall_status.py From unearth with Apache License 2.0 | 5 votes |
def fact(): """Returns the firewall status""" result = "None" plist = "/Library/Preferences/com.apple.alf.plist" firewall_status = CFPreferencesCopyAppValue("globalstate", plist) result = bool(firewall_status) return {factoid: result}