Beispiel #1
0
    def _create_response(self):
        data = None
        max_download_retries = self.max_download_retries
        for url in self.urls:

            # Create url for resource
            file_url = url + url_quote(self.filename)
            log.debug('Url for request: %s', file_url)
            try:
                data = self.http_pool.urlopen('GET',
                                              file_url,
                                              preload_content=False,
                                              retries=max_download_retries)
            except urllib3.exceptions.SSLError:
                log.debug('SSL cert not verified')
                continue
            except urllib3.exceptions.MaxRetryError:
                log.debug('MaxRetryError')
                continue
            except Exception as e:
                # Catch whatever else comes up and log it
                # to help fix other http related issues
                log.debug(str(e), exc_info=True)
            else:
                break

        if data is not None:
            log.debug('Resource URL: %s', file_url)
        else:
            log.debug('Could not create resource URL.')
        return data
Beispiel #2
0
    def _create_response(self):
        data = None
        max_download_retries = self.max_download_retries
        for url in self.urls:
            # Create url for resource
            file_url = url + url_quote(self.filename)
            log.debug('Url for request: %s', file_url)
            try:
                data = self.http_pool.urlopen('GET', file_url,
                                              preload_content=False,
                                              retries=max_download_retries)
            except urllib3.exceptions.SSLError:
                log.debug('SSL cert not verified')
                continue
            except urllib3.exceptions.MaxRetryError:
                log.debug('MaxRetryError')
                continue
            except Exception as e:
                # Catch whatever else comes up and log it
                # to help fix other http related issues
                log.debug(str(e), exc_info=True)
            else:
                if data.status != 200:
                    log.debug("Received a non-200 response %d", data.status)
                    data = None
                else:
                    break

        if data is not None:
            log.debug('Resource URL: %s', file_url)
        else:
            log.debug('Could not create resource URL.')
        return data