

def _get_response(self, endpoint, request_dict):
    ' Returns a dictionary of data requested by each function.\n\n        Arguments:\n        ----------\n        endpoint: string, mandatory\n            Set in all other methods, this is the API endpoint specific to each function.\n        request_dict: string, mandatory\n            A dictionary of parameters that are formatted into the API call.\n\n        Returns:\n        --------\n            response: A dictionary that has been dumped from JSON.\n\n        Raises:\n        -------\n            MesoPyError: Overrides the exceptions given in the requests library to give more custom error messages.\n            Connection_error occurs if no internet connection exists. Timeout_error occurs if the request takes too\n            long and redirect_error is shown if the url is formatted incorrectly.\n\n        '
    http_error = 'Could not connect to the API. This could be because you have no internet connection, a parameter was input incorrectly, or the API is currently down. Please try again.'
    try:
        qsp = urllib.parse.urlencode(request_dict, doseq=True)
        resp = urllib.request.urlopen((((self.base_url + endpoint) + '?') + qsp)).read()
    except (AttributeError or NameError):
        try:
            qsp = urllib.urlencode(request_dict, doseq=True)
            resp = urllib2.urlopen((((self.base_url + endpoint) + '?') + qsp)).read()
        except urllib2.URLError:
            raise MesoPyError(http_error)
    except urllib.error.URLError:
        raise MesoPyError(http_error)
    return self._checkresponse(json.loads(resp.decode('utf-8')))

dataset/ETHPy150Open mesowx/MesoPy/MesoPy.py Meso._get_response/original