Пример #1
0
    def _query(self):
        """Internal method to execute the query. Returns the output of the
        C{urllib2.urlopen} method of the standard Python library

        @return: tuples with the raw request plus the expected format.
        @raise QueryBadFormed: If the C{HTTP return code} is C{400}.
        @raise Unauthorized: If the C{HTTP return code} is C{401}.
        @raise EndPointNotFound: If the C{HTTP return code} is C{404}.
        @raise EndPointInternalError: If the C{HTTP return code} is C{500}.
        """
        request = self._createRequest()

        try:
            if self.timeout:
                response = urlopener(request, timeout=self.timeout)
            else:
                response = urlopener(request)
            return response, self.returnFormat
        except urllib2.HTTPError, e:
            if e.code == 400:
                raise QueryBadFormed(e.read())
            elif e.code == 404:
                raise EndPointNotFound(e.read())
            elif e.code == 401:
                raise Unauthorized(e.read())
            elif e.code == 500:
                raise EndPointInternalError(e.read())
            else:
                raise e
Пример #2
0
    def _query(self):
        """Internal method to execute the query. Returns the output of the
        C{urllib2.urlopen} method of the standard Python library

        @return: tuples with the raw request plus the expected format
        """
        if self.timeout:
            socket.setdefaulttimeout(self.timeout)

        request = self._createRequest()

        try:
            import ssl
            ctx = ssl.create_default_context()
            ctx.check_hostname = False
            ctx.verify_mode = ssl.CERT_NONE
            response = urlopener(request, context=ctx)
            #response = urlopener(request)
            return response, self.returnFormat
        except urllib2.HTTPError, e:
            if e.code == 400:
                raise QueryBadFormed(e.read())
            elif e.code == 404:
                raise EndPointNotFound(e.read())
            elif e.code == 500:
                raise EndPointInternalError(e.read())
            else:
                raise e
	def _query(self):
		if self.timeout:
			socket.setdefaulttimeout(self.timeout)
		request = self._createRequest()
		tmp = request.get_full_url().replace("format=json", "format=srj")
		request = urllib2.Request(tmp)
		try:
			response = urlopener(request)
			return response, self.returnFormat
		except urllib2.HTTPError, e:
			if e.code == 400:
				raise QueryBadFormed(e.read())
			elif e.code == 404:
				raise EndPointNotFound(e.read())
			elif e.code == 500:
				raise EndPointInternalError(e.read())
			else:
				print traceback.format_exc()
				raise e
Пример #4
0
	def _query(self):
		if self.timeout:
			socket.setdefaulttimeout(self.timeout)
		request = self._createRequest()
		tmp = request.get_full_url().replace("format=json", "format=srj")
		request = urllib2.Request(tmp)
		try:
			response = urlopener(request)
			return response, self.returnFormat
		except urllib2.HTTPError, e:
			if e.code == 400:
				raise QueryBadFormed(e.read())
			elif e.code == 404:
				raise EndPointNotFound(e.read())
			elif e.code == 500:
				raise EndPointInternalError(e.read())
			else:
				print traceback.format_exc()
				raise e
Пример #5
0
    def _query(self):
        """Internal method to execute the query. Returns the output of the
        C{urllib2.urlopen} method of the standard Python library

        @return: tuples with the raw request plus the expected format
        """
        if (self.timeout): socket.setdefaulttimeout(self.timeout)
        request = self._createRequest()
        try:
            response = urlopener(request)
            return response, self.returnFormat
        except urllib2.HTTPError, e:
            if e.code == 400:
                raise QueryBadFormed(e.read())
            elif e.code == 404:
                raise EndPointNotFound(e.read())
            elif e.code == 500:
                raise EndPointInternalError(e.read())
            else:
                raise e
Пример #6
0
    def _query(self):
        """Internal method to execute the query. Returns the output of the
        C{urllib2.urlopen} method of the standard Python library

        @return: tuples with the raw request plus the expected format
        """
        if (self.timeout): socket.setdefaulttimeout(self.timeout)
        request = self._createRequest()
        try:
            response = urlopener(request)
            return response, self.returnFormat
        except urllib2.HTTPError, e:
            if e.code == 400:
                raise QueryBadFormed(e.read())
            elif e.code == 404:
                raise EndPointNotFound(e.read())
            elif e.code == 500:
                raise EndPointInternalError(e.read())
            else:
                raise e