server/sources/datafeed.py
changeset 10532 2cc74c688eb9
parent 10522 1660a0fa4f43
child 10551 1182f5f16a3d
equal deleted inserted replaced
10531:51261952d068 10532:2cc74c688eb9
   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: