osnapi/core.py
def handle_response(query:str, response:requests.Response) -> Union[Dict, str]:
    """ If the HTTPS Status Code is 200, the json response will be returned as a dictionary.
        Otherwise an Exception with some information about the query is raised.
        If for some reason a conversion to json is not possible, uses the raw text representation.
    """
    try:    text = response.json()
    except: text = response.text
    if response.status_code == 200: return text

    info = f'\n--Status Code   : {response.status_code}\n--Request to    : {query}\n--Response Body : {text}'

    if response.status_code == 500 or response.status_code == 401:
        raise PermissionError(f'The Server has refused this request, due to you attempting something that requires authorization.\
        Try logging in and repeating the Request.{info}')

    if response.status_code == 408:
        raise Exception(f'The Server has closed this connection, probably due to the request being too large,\
        or the server being under heavy load. Try sending less data at once.{info}')

    raise Exception(f'Something went wrong with your request.{info}')
 If the HTTPS Status Code is 200, the json response will be returned as a dictionary.
        Otherwise an Exception with some information about the query is raised.
        If for some reason a conversion to json is not possible, uses the raw text representation.
    
If the HTTPS Status Code is 200, the json response will be returned as a dictionary.
Otherwise an Exception with some information about the query is raised.
If for some reason a conversion to json is not possible, uses the raw text representation.
If the HTTPS Status Code is 200 the json response will be returned as a dictionary . Otherwise an Exception with some information about the query is raised . If for some reason a conversion to json is not possible uses the raw text representation .
def handle_response(query:str, response:requests.Response) -> Union[Dict, str]:
    try:    text = response.json()
    except: text = response.text
    if response.status_code == 200: return text
    info = f'\n--Status Code   : {response.status_code}\n--Request to    : {query}\n--Response Body : {text}'
    if response.status_code == 500 or response.status_code == 401:
        raise PermissionError(f'The Server has refused this request, due to you attempting something that requires authorization.\
        Try logging in and repeating the Request.{info}')
    if response.status_code == 408:
        raise Exception(f'The Server has closed this connection, probably due to the request being too large,\
        or the server being under heavy load. Try sending less data at once.{info}')
    raise Exception(f'Something went wrong with your request.{info}')
def handle_response ( query : str , response : requests . Response ) -> Union [ Dict , str ] : try : text = response . json ( ) except : text = response . text if response . status_code == 200 : return text info = f'\n--Status Code   : {response.status_code}\n--Request to    : {query}\n--Response Body : {text}' if response . status_code == 500 or response . status_code == 401 : raise PermissionError ( f'The Server has refused this request, due to you attempting something that requires authorization.\
        Try logging in and repeating the Request.{info}' ) if response . status_code == 408 : raise Exception ( f'The Server has closed this connection, probably due to the request being too large,\
        or the server being under heavy load. Try sending less data at once.{info}' ) raise Exception ( f'Something went wrong with your request.{info}' )
If the HTTPS Status Code is 200, the json response will be returned as a dictionary.
If the HTTPS Status Code is 200 the json response will be returned as a dictionary .
""" If the HTTPS Status Code is 200, the json response will be returned as a dictionary.
        Otherwise an Exception with some information about the query is raised.
        If for some reason a conversion to json is not possible, uses the raw text representation.
    """
query
str
response
requests.Response