def validate_response(response, content=None):
    if response.getcode() != 200:
        raise AttributeError('HTTP code %d. %s' % (response.code, response.msg))

    if content is None:
        content = json.loads(response.read().decode('utf-8'))

    for error_field in ('error_msg', 'error'):
        if error_field in content:
            raise AttributeError('Error message from thermostat: %s' % content[error_field])
raises AttributeError if the HTTP response code is not 200, or if the value
dataset/ETHPy150Open mhrivnak/radiotherm/radiotherm/validate.py/validate_response