def _wrap_urlopen(url, timeout=None):
 try:
  raw = urlopen(url, timeout=timeout)
 except IOError as e:
  msg = (u'Error getting %s: %s' % (url, e))
  log.error(msg)
  raise RequestException(msg)
 resp = requests.Response()
 resp.raw = raw
 orig_read = raw.read
 resp.raw.read = (lambda size, **kwargs: orig_read(size))
 resp.status_code = (raw.code or 200)
 resp.headers = requests.structures.CaseInsensitiveDict(raw.headers)
 return resp

def _wrap_urlopen ( url , timeout = None ) : try : raw = urlopen ( url , timeout = timeout ) except IOError as e : msg = ( u'Error getting %s: %s' % ( url , e ) ) log . error ( msg ) raise RequestException ( msg ) resp = requests . Response ( ) resp . raw = raw orig_read = raw . read resp . raw . read = ( lambda size , ** kwargs : orig_read ( size ) ) resp . status_code = ( raw . code or 200 ) resp . headers = requests . structures . CaseInsensitiveDict ( raw . headers ) return resp
handles alternate schemes using urllib .