Changeset 5841


Ignore:
Timestamp:
14/10/09 10:41:09 (10 years ago)
Author:
pnorton
Message:

Improved the proxy code so that no errors occurr if the http_proxy environment variable is not set.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cowsclient/trunk/cowsclient/lib/wmc_util.py

    r5744 r5841  
    157157 
    158158def proxyFix(url): 
    159     oldProxyVal = os.environ['http_proxy'] 
    160  
    161     if os.environ['http_proxy'] != "" and not _shouldUseProxy(url): 
    162         os.environ['http_proxy'] = "" 
    163         reload(urllib2) 
     159    oldProxyVal = os.environ.get('http_proxy', None) 
     160     
     161    if oldProxyVal != None: 
     162        if os.environ['http_proxy'] != "" and not _shouldUseProxy(url): 
     163            os.environ['http_proxy'] = "" 
     164            reload(urllib2) 
    164165 
    165166    return oldProxyVal 
     
    167168 
    168169def resetProxy(oldProxyVal): 
     170     
     171    if oldProxyVal == None or oldProxyVal == "": 
     172        return 
     173     
    169174    if os.environ['http_proxy'] != oldProxyVal: 
    170175        os.environ['http_proxy'] = oldProxyVal 
Note: See TracChangeset for help on using the changeset viewer.