本文整理汇总了Python中Foundation.CFPreferencesCopyAppValue方法的典型用法代码示例。如果您正苦于以下问题:Python Foundation.CFPreferencesCopyAppValue方法的具体用法?Python Foundation.CFPreferencesCopyAppValue怎么用?Python Foundation.CFPreferencesCopyAppValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Foundation
的用法示例。
在下文中一共展示了Foundation.CFPreferencesCopyAppValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: read_prefs
# 需要导入模块: import Foundation [as 别名]
# 或者: from Foundation import CFPreferencesCopyAppValue [as 别名]
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
示例2: check_and_disable_appnap_for_pdapp
# 需要导入模块: import Foundation [as 别名]
# 或者: from Foundation import CFPreferencesCopyAppValue [as 别名]
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')
示例3: _read_pref
# 需要导入模块: import Foundation [as 别名]
# 或者: from Foundation import CFPreferencesCopyAppValue [as 别名]
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)
示例4: get_monolith_auth_header
# 需要导入模块: import Foundation [as 别名]
# 或者: from Foundation import CFPreferencesCopyAppValue [as 别名]
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"
示例5: main
# 需要导入模块: import Foundation [as 别名]
# 或者: from Foundation import CFPreferencesCopyAppValue [as 别名]
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)
示例6: fact
# 需要导入模块: import Foundation [as 别名]
# 或者: from Foundation import CFPreferencesCopyAppValue [as 别名]
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}