Python objc.super() Examples

The following are 8 code examples of objc.super(). 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 objc , or try the search function .
Example #1
Source File: nsurlsession_adapter.py    From python-jss with GNU General Public License v3.0 6 votes vote down vote up
def initWithAdapter_(self, adapter):
        self = objc.super(NSURLSessionAdapterDelegate, self).init()

        if self is None:
            return None

        self.adapter = adapter
        self.bytesReceived = 0
        self.expectedLength = -1
        self.percentComplete = 0
        self.done = False
        self.error = None
        self.SSLError = None
        self.output = NSMutableData.dataWithCapacity_(1024)
        self.status = None
        self.headers = {}
        self.verify = True
        self.credential = None
        self.history = []

        return self 
Example #2
Source File: nsurlsession_adapter.py    From python-jss with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, credential=None, force_basic=False):
        # type: (Optional[NSURLCredential], bool) -> None
        """NSURLSessionAdapter implements a requests adapter using PyObjC + NSURLSession.

        Because of the way the delegate deals with authentication, we cannot support requests style auth which may only
        act on the content of the request. For NSURLSessionAdapter you should use NSURLCredentialAuth, which supplies an
        NSURLCredential object whenever authentication is required by the remote host.

        :param credential: NSURLCredential that will be used if the server requests basic auth.
        :param force_basic: Force basic authentication to be used for every request by preparing the Authorization
            header. This is sometimes required because NSURLSession only checks with the delegate for credentials when
            the server sends a "challenge". Some web services never even send a challenge.
        """
        super(NSURLSessionAdapter, self).__init__()

        self.verify = True
        self.credential = credential
        self.force_basic = force_basic
        self.configuration = None
        self.delegate = None
        self.session = None 
Example #3
Source File: protocol.py    From EDMarketConnector with GNU General Public License v2.0 5 votes vote down vote up
def init(self):
            self = objc.super(EventHandler, self).init()
            NSAppleEventManager.sharedAppleEventManager().setEventHandler_andSelector_forEventClass_andEventID_(self, 'handleEvent:withReplyEvent:', kInternetEventClass, kAEGetURL)
            return self 
Example #4
Source File: CentralManagerDelegate.py    From bleak with MIT License 5 votes vote down vote up
def init(self):
        """macOS init function for NSObject"""
        self = objc.super(CentralManagerDelegate, self).init()

        if self is None:
            return None

        self.event_loop = asyncio.get_event_loop()
        self.connected_peripheral_delegate = None
        self.connected_peripheral = None
        self._connection_state = CMDConnectionState.DISCONNECTED

        self.powered_on_event = asyncio.Event()
        self.devices = {}

        self.callbacks = {}
        self.disconnected_callback = None

        if not self.compliant():
            logger.warning("CentralManagerDelegate is not compliant")

        self.central_manager = CBCentralManager.alloc().initWithDelegate_queue_(
            self, dispatch_queue_create(b"bleak.corebluetooth", DISPATCH_QUEUE_SERIAL)
        )

        return self

    # User defined functions 
Example #5
Source File: PeripheralDelegate.py    From bleak with MIT License 5 votes vote down vote up
def initWithPeripheral_(self, peripheral: CBPeripheral):
        """macOS init function for NSObject"""
        self = objc.super(PeripheralDelegate, self).init()

        if self is None:
            return None

        self.peripheral = peripheral
        self.peripheral.setDelegate_(self)

        self._event_loop = asyncio.get_event_loop()
        self._services_discovered_event = asyncio.Event()

        self._service_characteristic_discovered_events = _EventDict()
        self._characteristic_descriptor_discover_events = _EventDict()

        self._characteristic_read_events = _EventDict()
        self._characteristic_write_events = _EventDict()

        self._descriptor_read_events = _EventDict()
        self._descriptor_write_events = _EventDict()

        self._characteristic_notify_change_events = _EventDict()
        self._characteristic_notify_callbacks = {}

        if not self.compliant():
            logger.warning("PeripheralDelegate is not compliant")

        return self 
Example #6
Source File: gurl.py    From installapplications with Apache License 2.0 5 votes vote down vote up
def initWithOptions_(self, options):
        '''Set up our Gurl object'''
        self = super(Gurl, self).init()
        if not self:
            return None

        self.follow_redirects = options.get('follow_redirects', False)
        self.ignore_system_proxy = options.get('ignore_system_proxy', False)
        self.destination_path = options.get('file')
        self.can_resume = options.get('can_resume', False)
        self.url = options.get('url')
        self.additional_headers = options.get('additional_headers', {})
        self.username = options.get('username')
        self.password = options.get('password')
        self.download_only_if_changed = options.get(
            'download_only_if_changed', False)
        self.cache_data = options.get('cache_data')
        self.connection_timeout = options.get('connection_timeout', 60)
        if NSURLSESSION_AVAILABLE:
            self.minimum_tls_protocol = options.get(
                'minimum_tls_protocol', kTLSProtocol1)

        self.log = options.get('logging_function', NSLogWrapper)

        self.resume = False
        self.response = None
        self.headers = None
        self.status = None
        self.error = None
        self.SSLerror = None
        self.done = False
        self.redirection = []
        self.destination = None
        self.bytesReceived = 0
        self.expectedLength = -1
        self.percentComplete = 0
        self.connection = None
        self.session = None
        self.task = None
        return self 
Example #7
Source File: gurl.py    From python-jss with GNU General Public License v3.0 5 votes vote down vote up
def initWithOptions_(self, options):
        '''Set up our Gurl object'''
        self = super(Gurl, self).init()
        if not self:
            return None

        self.follow_redirects = options.get('follow_redirects', False)
        self.ignore_system_proxy = options.get('ignore_system_proxy', False)
        self.destination_path = options.get('file')
        self.can_resume = options.get('can_resume', False)
        self.url = options.get('url')
        self.additional_headers = options.get('additional_headers', {})
        self.username = options.get('username')
        self.password = options.get('password')
        self.download_only_if_changed = options.get(
            'download_only_if_changed', False)
        self.cache_data = options.get('cache_data')
        self.connection_timeout = options.get('connection_timeout', 60)
        if NSURLSESSION_AVAILABLE:
            self.minimum_tls_protocol = options.get(
                'minimum_tls_protocol', kTLSProtocol1)

        self.log = options.get('logging_function', NSLogWrapper)

        self.resume = False
        self.response = None
        self.headers = None
        self.status = None
        self.error = None
        self.SSLerror = None
        self.done = False
        self.redirection = []
        self.destination = None
        self.bytesReceived = 0
        self.expectedLength = -1
        self.percentComplete = 0
        self.connection = None
        self.session = None
        self.task = None
        return self 
Example #8
Source File: gurl.py    From nudge with Apache License 2.0 5 votes vote down vote up
def initWithOptions_(self, options):
        '''Set up our Gurl object'''
        self = super(Gurl, self).init()
        if not self:
            return None

        self.follow_redirects = options.get('follow_redirects', False)
        self.ignore_system_proxy = options.get('ignore_system_proxy', False)
        self.destination_path = options.get('file')
        self.can_resume = options.get('can_resume', False)
        self.url = options.get('url')
        self.additional_headers = options.get('additional_headers', {})
        self.username = options.get('username')
        self.password = options.get('password')
        self.download_only_if_changed = options.get(
            'download_only_if_changed', False)
        self.cache_data = options.get('cache_data')
        self.connection_timeout = options.get('connection_timeout', 60)
        if NSURLSESSION_AVAILABLE:
            self.minimum_tls_protocol = options.get(
                'minimum_tls_protocol', kTLSProtocol1)

        self.log = options.get('logging_function', NSLogWrapper)

        self.resume = False
        self.response = None
        self.headers = None
        self.status = None
        self.error = None
        self.SSLerror = None
        self.done = False
        self.redirection = []
        self.destination = None
        self.bytesReceived = 0
        self.expectedLength = -1
        self.percentComplete = 0
        self.connection = None
        self.session = None
        self.task = None
        return self