scout/utils/requests.py
def get_request(url):
    """Return a requests response from url
    
    Args:
        url(str)
    
    Returns:
        decoded_data(str): Decoded response
    """
    try:
        LOG.info("Requesting %s", url)
        response = urllib.request.urlopen(url)
        if url.endswith('.gz'):
            LOG.info("Decompress zipped file")
            data = gzip.decompress(response.read())      # a `bytes` object
        else:
            data = response.read()      # a `bytes` object
        decoded_data = data.decode('utf-8')
    except HTTPError as err:
        LOG.warning("Something went wrong, perhaps the api key is not valid?")
        raise err
    except URLError as err:
        LOG.warning("Something went wrong, are you connected to internet?")
        raise err
    
    if 'Error' in decoded_data:
        raise URLError("Seems like url {} does not exist".format(url))
    
    return decoded_data
def get_request(url):
    """Return a requests response from url
    
    Args:
        url(str)
    
    Returns:
        decoded_data(str): Decoded response
    """
    try:
        LOG.info("Requesting %s", url)
        response = urllib.request.urlopen(url)
        if url.endswith('.gz'):
            LOG.info("Decompress zipped file")
            data = gzip.decompress(response.read())      # a `bytes` object
        else:
            data = response.read()      # a `bytes` object
        decoded_data = data.decode('utf-8')
    except HTTPError as err:
        LOG.warning("Something went wrong, perhaps the api key is not valid?")
        raise err
    except URLError as err:
        LOG.warning("Something went wrong, are you connected to internet?")
        raise err
    
    if 'Error' in decoded_data:
        raise URLError("Seems like url {} does not exist".format(url))
    
    return decoded_data
Return a requests response from url
    
    Args:
        url(str)
    
    Returns:
        decoded_data(str): Decoded response