Ejemplo n.º 1
0
 def exception_handler(req, ex):
     msg = "Failed to download " + req.url
     if isinstance(ex, requests.exceptions.Timeout):
         msg = "Connection timed out: %(ex)s (%(url)s)" % {"ex": ex.__str__(), "url": req.url}
     elif isinstance(ex, requests.exceptions.RequestException):
         msg = "Error downloading: %(ex)s (%(url)s)" % {"ex": ex, "url": req.url}
     else:
         msg = " ".join([msg, str(ex)])
     errors.append(req.url)
     logger.error(msg)
Ejemplo n.º 2
0
 def exception_handler(req, ex):
     msg = 'Failed to download ' + req.url
     if isinstance(ex, requests.exceptions.Timeout):
         msg = 'Connection timed out: %(ex)s (%(url)s)' % {'ex': ex.__str__(), 'url': req.url}
     elif isinstance(ex, requests.exceptions.RequestException):
         msg = 'Error downloading: %(ex)s (%(url)s)' % {'ex': ex, 'url': req.url}
     else:
         msg = ' '.join([msg, str(ex)])
     errors.append(req.url)
     logger.error(msg)
Ejemplo n.º 3
0
 def _download(self, url):
     logger.info("Download started: " + url)
     try:
         r = requests.get(url)
         logger.info("Download completed: " + url)
         if r.status_code == 200:
             return r.content
         r.raise_for_status()
     except requests.exceptions.Timeout as e:
         logger.error("Connection timed out: " + e.__str__())
     except requests.exceptions.RequestException as e:
         logger.error("Error downloading: " + e.__str__())
     return None
Ejemplo n.º 4
0
 def _download(self, url):
     logger.info('Download started: ' + url)
     try:
         r = requests.get(url)
         logger.info('Download completed: ' + url)
         if r.status_code == 200:
             return r.content
         r.raise_for_status()
     except requests.exceptions.Timeout as e:
         logger.error('Connection timed out: ' + e.__str__())
     except requests.exceptions.RequestException as e:
         logger.error('Error downloading: ' + e.__str__())
     return None