Fix KeyError on no 'no_proxy' env var

This commit is contained in:
Strahinja Val Markovic 2014-09-11 15:19:26 -07:00
parent 146bfca574
commit 24bbcf8811

View File

@ -46,6 +46,12 @@ try:
except ImportError: except ImportError:
USE_ULTISNIPS_DATA = False USE_ULTISNIPS_DATA = False
def PatchNoProxy():
current_value = os.environ.get('no_proxy', '')
additions = '127.0.0.1,localhost'
os.environ['no_proxy'] = ( additions if not current_value
else current_value + ',' + additions )
# We need this so that Requests doesn't end up using the local HTTP proxy when # We need this so that Requests doesn't end up using the local HTTP proxy when
# talking to ycmd. Users should actually be setting this themselves when # talking to ycmd. Users should actually be setting this themselves when
# configuring a proxy server on their machine, but most don't know they need to # configuring a proxy server on their machine, but most don't know they need to
@ -53,7 +59,7 @@ except ImportError:
# Relevant issues: # Relevant issues:
# https://github.com/Valloric/YouCompleteMe/issues/641 # https://github.com/Valloric/YouCompleteMe/issues/641
# https://github.com/kennethreitz/requests/issues/879 # https://github.com/kennethreitz/requests/issues/879
os.environ['no_proxy'] = os.environ['no_proxy'] + (',' if len (os.environ['no_proxy']) > 0 else '') + '127.0.0.1,localhost' PatchNoProxy()
# Force the Python interpreter embedded in Vim (in which we are running) to # Force the Python interpreter embedded in Vim (in which we are running) to
# ignore the SIGINT signal. This helps reduce the fallout of a user pressing # ignore the SIGINT signal. This helps reduce the fallout of a user pressing