343 cnx.timeout = self.source.http_timeout |
343 cnx.timeout = self.source.http_timeout |
344 self.source.info('Using cwclientlib for %s' % url) |
344 self.source.info('Using cwclientlib for %s' % url) |
345 resp = cnx.get(url) |
345 resp = cnx.get(url) |
346 resp.raise_for_status() |
346 resp.raise_for_status() |
347 return URLLibResponseAdapter(StringIO.StringIO(resp.text), url) |
347 return URLLibResponseAdapter(StringIO.StringIO(resp.text), url) |
348 except (ImportError, ValueError) as exc: |
348 except (ImportError, ValueError, EnvironmentError) as exc: |
349 # ImportError: not available |
349 # ImportError: not available |
350 # ValueError: no config entry found |
350 # ValueError: no config entry found |
|
351 # EnvironmentError: no cwclientlib config file found |
351 self.source.debug(str(exc)) |
352 self.source.debug(str(exc)) |
352 |
353 |
353 # no chance with cwclientlib, fall back to former implementation |
354 # no chance with cwclientlib, fall back to former implementation |
354 if purl.scheme in ('http', 'https'): |
355 if purl.scheme in ('http', 'https'): |
355 self.source.info('GET %s', url) |
356 self.source.info('GET %s', url) |
520 # parse url again since it has been normalized |
521 # parse url again since it has been normalized |
521 cnx = cwproxy_for(url) |
522 cnx = cwproxy_for(url) |
522 cnx.timeout = self.source.http_timeout |
523 cnx.timeout = self.source.http_timeout |
523 self.source.info('Using cwclientlib for checking %s' % url) |
524 self.source.info('Using cwclientlib for checking %s' % url) |
524 return cnx.get(url).status_code == 404 |
525 return cnx.get(url).status_code == 404 |
525 except (ImportError, ValueError) as exc: |
526 except (ImportError, ValueError, EnvironmentError) as exc: |
526 # ImportError: not available |
527 # ImportError: not available |
527 # ValueError: no config entry found |
528 # ValueError: no config entry found |
|
529 # EnvironmentError: no cwclientlib config file found |
528 self.source.debug(str(exc)) |
530 self.source.debug(str(exc)) |
529 |
531 |
530 # no chance with cwclientlib, fall back to former implementation |
532 # no chance with cwclientlib, fall back to former implementation |
531 if urlparse.urlparse(url).scheme in ('http', 'https'): |
533 if urlparse.urlparse(url).scheme in ('http', 'https'): |
532 try: |
534 try: |