How to use the somecomfort.client.APIRateLimited function in somecomfort

To help you get started, we’ve selected a few somecomfort examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kk7ds / somecomfort / somecomfort / client.py View on Github external
def _request_json(self, method, *args, **kwargs):
        if 'timeout' not in kwargs:
            kwargs['timeout'] = self._timeout

        resp = getattr(self._session, method)(*args, **kwargs)
        req = args[0].replace(self._baseurl, '')

        if resp.status_code == 200:
            return self._resp_json(resp, req)
        elif resp.status_code == 401:
            raise APIRateLimited()
        else:
            _LOG.error('API returned %i from %s request',
                       resp.status_code, req)
            raise APIError('Unexpected %i response from API' % (
                resp.status_code))
github kk7ds / somecomfort / somecomfort / client.py View on Github external
def __init__(self):
        super(APIRateLimited, self).__init__(
            'You are being rate-limited. Try waiting a bit.')