コード例 #1
0
ファイル: connection.py プロジェクト: jkettleb/esgf-pyclient
    def _send_query(self, endpoint, full_query):
        """
        Generally not to be called directly by the user but via SearchContext
    instances.
        
        :param full_query: dictionary of query string parameers to send.
        :return: the urllib2 response object from the query.
        
        """

        log.debug('Query dict is %s' % full_query)

        query_url = '%s/%s?%s' % (self.url, endpoint, urlencode(full_query))
        log.debug('Query request is %s' % query_url)

        try:
            response = urllib2.urlopen(query_url)
        except urllib2.HTTPError, err:
            log.warn("HTTP request received error code: %s" % err.code)
            if err.code == 400:
                errors = set(re.findall("Invalid HTTP query parameter=(\w+)", err.fp.read()))
                content = "; ".join([e for e in list(errors)])
                raise Exception("Invalid query parameter(s): %s" % content)
            else:
                raise Exception("Error returned from URL: %s" % query_url)
コード例 #2
0
ファイル: connection.py プロジェクト: jkettleb/esgf-pyclient
    def _send_query(self, endpoint, full_query):
        """
        Generally not to be called directly by the user but via SearchContext
    instances.
        
        :param full_query: dictionary of query string parameers to send.
        :return: the urllib2 response object from the query.
        
        """

        log.debug('Query dict is %s' % full_query)

        query_url = '%s/%s?%s' % (self.url, endpoint, urlencode(full_query))
        log.debug('Query request is %s' % query_url)

        try:
            response = urllib2.urlopen(query_url)
        except urllib2.HTTPError, err:
            log.warn("HTTP request received error code: %s" % err.code)
            if err.code == 400:
                errors = set(
                    re.findall("Invalid HTTP query parameter=(\w+)",
                               err.fp.read()))
                content = "; ".join([e for e in list(errors)])
                raise Exception("Invalid query parameter(s): %s" % content)
            else:
                raise Exception("Error returned from URL: %s" % query_url)
コード例 #3
0
    def _send_query(self, endpoint, full_query):
        """
        Generally not to be called directly by the user but via SearchContext
	instances.
        
        :param full_query: dictionary of query string parameers to send.
        :return: the urllib2 response object from the query.
        
        """

        log.debug('Query dict is %s' % full_query)

        query_url = '%s/%s?%s' % (self.url, endpoint, urlencode(full_query))
        log.debug('Query request is %s' % query_url)

        response = urllib2.urlopen(query_url)

        return response
コード例 #4
0
    def _send_query(self, endpoint, full_query):
        """
        Generally not to be called directly by the user but via SearchContext
	instances.
        
        :param full_query: dictionary of query string parameers to send.
        :return: the urllib2 response object from the query.
        
        """

        log.debug('Query dict is %s' % full_query)

        query_url = '%s/%s?%s' % (self.url, endpoint, urlencode(full_query))
        log.debug('Query request is %s' % query_url)

        response = urllib2.urlopen(query_url)

        return response