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


Python objc.loadBundle方法代码示例

本文整理汇总了Python中objc.loadBundle方法的典型用法代码示例。如果您正苦于以下问题:Python objc.loadBundle方法的具体用法?Python objc.loadBundle怎么用?Python objc.loadBundle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在objc的用法示例。


在下文中一共展示了objc.loadBundle方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: fact

# 需要导入模块: import objc [as 别名]
# 或者: from objc import loadBundle [as 别名]
def fact():
    """Returns the wifi ssid of the Mac"""
    wifi_ssid = None

    objc.loadBundle(
        "CoreWLAN",
        bundle_path="/System/Library/Frameworks/CoreWLAN.framework",
        module_globals=globals(),
    )

    wifi = CWInterface.interfaceNames()
    if wifi:
        for iname in wifi:
            interface = CWInterface.interfaceWithName_(iname)
        if interface:
            try:
                wifi_ssid = interface.ssid()
            except AttributeError:
                pass

    return {factoid: wifi_ssid} 
开发者ID:chilcote,项目名称:unearth,代码行数:23,代码来源:wifi_ssid.py

示例2: fact

# 需要导入模块: import objc [as 别名]
# 或者: from objc import loadBundle [as 别名]
def fact():
    """Returns the current bluetooth sharing"""

    result = "None"

    objc.loadBundle(
        "IOBluetooth",
        globals(),
        bundle_path=objc.pathForFramework(
            u"/System/Library/Frameworks/IOBluetooth.framework"
        ),
    )
    btprefs = IOBluetoothPreferences.alloc().init()
    result = bool(btprefs.fileTransferServicesEnabled())

    return {factoid: result} 
开发者ID:chilcote,项目名称:unearth,代码行数:18,代码来源:bluetooth_sharing.py

示例3: fact

# 需要导入模块: import objc [as 别名]
# 或者: from objc import loadBundle [as 别名]
def fact():
    """Returns the wifi power status of the Mac"""
    wifi_status = None
    objc.loadBundle(
        "CoreWLAN",
        bundle_path="/System/Library/Frameworks/CoreWLAN.framework",
        module_globals=globals(),
    )

    wifi = CWInterface.interfaceNames()
    if wifi:
        for iname in wifi:
            interface = CWInterface.interfaceWithName_(iname)
        try:
            wifi_status = "On" if interface.powerOn() == 1 else "Off"
        except AttributeError:
            wifi_status = None
    return {factoid: wifi_status} 
开发者ID:chilcote,项目名称:unearth,代码行数:20,代码来源:wifi_status.py

示例4: _loadBundle

# 需要导入模块: import objc [as 别名]
# 或者: from objc import loadBundle [as 别名]
def _loadBundle(frameworkName, frameworkIdentifier, frameworkPath):
    if frameworkIdentifier is None:
        bundle = loadBundle(
            frameworkName, {}, bundle_path=frameworkPath, scan_classes=False
        )

    else:
        try:
            bundle = loadBundle(
                frameworkName,
                {},
                bundle_identifier=frameworkIdentifier,
                scan_classes=False,
            )

        except ImportError:
            bundle = loadBundle(
                frameworkName, {}, bundle_path=frameworkPath, scan_classes=False
            )

    return bundle 
开发者ID:mass-immersion-approach,项目名称:MIA-Dictionary-Addon,代码行数:23,代码来源:_lazyimport.py

示例5: __init__

# 需要导入模块: import objc [as 别名]
# 或者: from objc import loadBundle [as 别名]
def __init__(self, master):
            try:
                objc.loadBundle('Sparkle', globals(), join(dirname(sys.executable.decode(sys.getfilesystemencoding())), os.pardir, 'Frameworks', 'Sparkle.framework'))
                self.updater = SUUpdater.sharedUpdater()
            except:
                # can't load framework - not frozen or not included in app bundle?
                self.updater = None 
开发者ID:EDCD,项目名称:EDMarketConnector,代码行数:9,代码来源:update.py

示例6: _load_objc_framework

# 需要导入模块: import objc [as 别名]
# 或者: from objc import loadBundle [as 别名]
def _load_objc_framework(framework_name):
    """Load an ObjC Framework bundle.

    :param str framework_name: framework_name (str): The name of the
        framework to load.

    :return: Generic class instance with public framework contents
        attached as attributes and methods.

    :rtype: object
    """
    log.trace('wifi._load_objc_framework: loading {}.'.format(framework_name))
    loaded_classes = dict()
    framework_bundle = objc.loadBundle(
        framework_name,
        bundle_path=os.path.dirname(ctypes.util.find_library(framework_name)),
        module_globals=loaded_classes)

    class AttributedFramework():
        pass

    framework = AttributedFramework()
    for name, loaded_class in loaded_classes.items():
        if not name.startswith('_'):
            setattr(framework, name, loaded_class)
    return framework 
开发者ID:mosen,项目名称:salt-osx,代码行数:28,代码来源:mac_wifi.py

示例7: get_updater

# 需要导入模块: import objc [as 别名]
# 或者: from objc import loadBundle [as 别名]
def get_updater():
    if sys.platform == 'darwin' and getattr(sys, 'frozen', False):
        """
        Use Sparkle framework on macOS.

        Settings: https://sparkle-project.org/documentation/customization/
        Examples: https://programtalk.com/python-examples/objc.loadBundle/

        To debug:
        $ defaults read com.borgbase.client.macos
        """

        import objc
        import Cocoa
        bundle_path = os.path.join(os.path.dirname(sys.executable), os.pardir, 'Frameworks', 'Sparkle.framework')
        objc.loadBundle('Sparkle', globals(), bundle_path)
        sparkle = SUUpdater.sharedUpdater()  # noqa: F821

        # A default Appcast URL is set in vorta.spec, when setting it here it's saved to defaults,
        # so we need both cases.
        if SettingsModel.get(key='updates_include_beta').value:
            appcast_nsurl = Cocoa.NSURL.URLWithString_('https://borgbase.github.io/vorta/appcast-pre.xml')
        else:
            appcast_nsurl = Cocoa.NSURL.URLWithString_('https://borgbase.github.io/vorta/appcast.xml')

        sparkle.setFeedURL_(appcast_nsurl)

        if SettingsModel.get(key='check_for_updates').value:
            sparkle.setAutomaticallyChecksForUpdates_(True)
            sparkle.checkForUpdatesInBackground()

        sparkle.setAutomaticallyDownloadsUpdates_(False)
        return sparkle

    else:  # TODO: implement for Linux
        return None 
开发者ID:borgbase,项目名称:vorta,代码行数:38,代码来源:updater.py

示例8: run_event_loop

# 需要导入模块: import objc [as 别名]
# 或者: from objc import loadBundle [as 别名]
def run_event_loop():
    logger.info('try to load mac hotkey event loop')
    # Set up a tap, with type of tap, location, options and event mask

    def create_tap():
        return Quartz.CGEventTapCreate(
            Quartz.kCGSessionEventTap,  # Session level is enough for our needs
            Quartz.kCGHeadInsertEventTap,  # Insert wherever, we do not filter
            Quartz.kCGEventTapOptionDefault,
            # NSSystemDefined for media keys
            Quartz.CGEventMaskBit(NSSystemDefined),
            keyboard_tap_callback,
            None
        )
    tap = create_tap()
    if tap is None:
        logger.error('Error occurred when trying to listen global hotkey. '
                     'trying to popup a prompt dialog to ask for permission.')
        # we do not use pyobjc-framework-ApplicationServices directly, since it
        # causes segfault when call AXIsProcessTrustedWithOptions function
        import objc
        AS = objc.loadBundle('CoreServices', globals(),
                             '/System/Library/Frameworks/ApplicationServices.framework')
        objc.loadBundleFunctions(AS, globals(),
                                 [('AXIsProcessTrustedWithOptions', b'Z@')])
        objc.loadBundleVariables(AS, globals(),
                                 [('kAXTrustedCheckOptionPrompt', b'@')])
        trusted = AXIsProcessTrustedWithOptions({kAXTrustedCheckOptionPrompt: True})  # noqa
        if not trusted:
            logger.info('Have popuped a prompt dialog to ask for accessibility.'
                        'You can restart feeluown after you grant access to it.')
        else:
            logger.warning('Have already grant accessibility, '
                           'but we still can not listen global hotkey,'
                           'theoretically, this should not happen.')
        return

    run_loop_source = Quartz.CFMachPortCreateRunLoopSource(
        None, tap, 0)
    Quartz.CFRunLoopAddSource(
        Quartz.CFRunLoopGetCurrent(),
        run_loop_source,
        Quartz.kCFRunLoopDefaultMode
    )
    # Enable the tap
    Quartz.CGEventTapEnable(tap, True)
    # and run! This won't return until we exit or are terminated.
    Quartz.CFRunLoopRun()
    logger.error('mac hotkey event loop exit')
    return [] 
开发者ID:feeluown,项目名称:FeelUOwn,代码行数:52,代码来源:global_hotkey_mac.py


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