Exemplo n.º 1
0
 async def request_events(ace_session, url):
     client = HTTPClient(client_id = CLIENT_ID,
                         client_secret = CLIENT_SECRET
                         )
     events_response = await client.access_resource(session = ace_session,
                                                    rs_url = url,
                                                    endpoint = '/events')
     return multi_loads(events_response)
Exemplo n.º 2
0
 async def request_events(ace_session):
     protocol = await Context.create_client_context()
     client = CoAPClient(client_id = CLIENT_ID,
                         client_secret = CLIENT_SECRET,
                         protocol = protocol
                         )
     events_response = await client.access_resource(session = ace_session,
                                                 rs_url = self.url,
                                                 endpoint = '/events')
     return multi_loads(events_response)
Exemplo n.º 3
0
    def poll(self, stop_event):
        while not stop_event.wait(1):
            time.sleep(_POLL_INTERVAL)
            try:
                self.update()

                logging.info('Device : ' + multi_loads(self.name) + ' was polled.')
            except Exception as e:
                logging.info('Polling failed:  ' + str(e))
                continue
Exemplo n.º 4
0
        async def request():
            _session = aiohttp.ClientSession()
            response = None

            if method == 'GET':
                response = await _session.get(url)
            elif method == 'PUT':
                response = await _session.put(url, headers = headers, data = data)
            elif method == 'POST':
                response = await _session.post(url, headers = headers, data = data)

            try:
                response_content = await response.read()
            except Exception:
                response_content = b''

            await _session.close()

            return multi_loads(response_content)