当前位置: 首页>>代码示例>>Python>>正文


Python Foundation.CFPreferencesCopyAppValue方法代码示例

本文整理汇总了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 
开发者ID:ANTS-Framework,项目名称:ants,代码行数:18,代码来源:macos_prefs.py

示例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') 
开发者ID:autopkg,项目名称:adobe-ccp-recipes,代码行数:20,代码来源:CreativeCloudPackager.py

示例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) 
开发者ID:mosen,项目名称:salt-osx,代码行数:35,代码来源:mac_prefs.py

示例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" 
开发者ID:zentralopensource,项目名称:zentral,代码行数:7,代码来源:run_once.py

示例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) 
开发者ID:salopensource,项目名称:sal,代码行数:13,代码来源:ard_info.py

示例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} 
开发者ID:chilcote,项目名称:unearth,代码行数:11,代码来源:firewall_status.py


注:本文中的Foundation.CFPreferencesCopyAppValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。