def tryProxy(handler, URL=None):
 if (URL is None):
  URL = 'http://www.google.com'
 req = urllib.request.Request(URL)
 opener = urllib.request.build_opener(handler)
 try:
  opener.open(req, timeout=2).read(5)
  return True
 except urllib.error.URLError as err:
  return err
 except urllib.error.HTTPError as err:
  return err

def tryProxy ( handler , URL = None ) : if ( URL is None ) : URL = 'http://www.google.com' req = urllib . request . Request ( URL ) opener = urllib . request . build_opener ( handler ) try : opener . open ( req , timeout = 2 ) . read ( 5 ) return True except urllib . error . URLError as err : return err except urllib . error . HTTPError as err : return err
test whether we can connect to a url with the current proxy settings .