Пример #1
0
    def load_cdx(self, query):
        if self.remote_processing:
            remote_query = query
        else:
            # Only send url and matchType to remote
            remote_query = CDXQuery(url=query.url, match_type=query.match_type)

        urlparams = remote_query.urlencode()

        try:
            request = urllib2.Request(self.remote_url + '?' + urlparams)

            if self.cookie:
                request.add_header('Cookie', self.cookie)

            response = urllib2.urlopen(request)

        except urllib2.HTTPError as e:
            if e.code == 403:
                raise AccessException('Access Denied')
            elif e.code == 404:
                # return empty list for consistency with other cdx sources
                # will be converted to 404 if no other retry
                return []
            elif e.code == 400:
                raise BadRequestException()
            else:
                raise WbException('Invalid response from remote cdx server')

        return iter(response)
Пример #2
0
    def load_cdx(self, query):
        if self.remote_processing:
            remote_query = query
        else:
            # Only send url and matchType to remote
            remote_query = CDXQuery(url=query.url,
                                    match_type=query.match_type)

        urlparams = remote_query.urlencode()

        try:
            request = urllib2.Request(self.remote_url + '?' + urlparams)

            if self.cookie:
                request.add_header('Cookie', self.cookie)

            response = urllib2.urlopen(request)

        except urllib2.HTTPError as e:
            if e.code == 403:
                raise AccessException('Access Denied')
            elif e.code == 404:
                # return empty list for consistency with other cdx sources
                # will be converted to 404 if no other retry
                return []
            elif e.code == 400:
                raise BadRequestException()
            else:
                raise WbException('Invalid response from remote cdx server')

        return iter(response)
Пример #3
0
    def load_cdx(self, **params):
        query = CDXQuery(**params)

        key, end_key = self._calc_search_keys(query)

        query.set_key(key, end_key)

        cdx_iter = self._load_cdx_query(query)

        return self._check_cdx_iter(cdx_iter, query)
Пример #4
0
    def load_cdx(self, **params):
        query = CDXQuery(**params)

        key, end_key = self._calc_search_keys(query)

        query.set_key(key, end_key)

        cdx_iter = self._load_cdx_query(query)

        return self._check_cdx_iter(cdx_iter, query)