def proxy_info_from_environment(method='http'):
 if (method not in ['http', 'https']):
  return
 env_var = (method + '_proxy')
 url = os.environ.get(env_var, os.environ.get(env_var.upper()))
 if (not url):
  return
 pi = proxy_info_from_url(url, method)
 no_proxy = os.environ.get('no_proxy', os.environ.get('NO_PROXY', ''))
 bypass_hosts = []
 if no_proxy:
  bypass_hosts = no_proxy.split(',')
 if (no_proxy == '*'):
  bypass_hosts = AllHosts
 pi.bypass_hosts = bypass_hosts
 return pi

def proxy_info_from_environment ( method = 'http' ) : if ( method not in [ 'http' , 'https' ] ) : return env_var = ( method + '_proxy' ) url = os . environ . get ( env_var , os . environ . get ( env_var . upper ( ) ) ) if ( not url ) : return pi = proxy_info_from_url ( url , method ) no_proxy = os . environ . get ( 'no_proxy' , os . environ . get ( 'NO_PROXY' , '' ) ) bypass_hosts = [ ] if no_proxy : bypass_hosts = no_proxy . split ( ',' ) if ( no_proxy == '*' ) : bypass_hosts = AllHosts pi . bypass_hosts = bypass_hosts return pi
read proxy info from the environment variables .