Skip to content

Commit

Permalink
port conda#6205 to master (conda#8654)
Browse files Browse the repository at this point in the history
port conda#6205 to master
  • Loading branch information
msarahan authored May 14, 2019
2 parents 7c3020c + d37fc74 commit 9208a96
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
7 changes: 5 additions & 2 deletions conda/core/subdir_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
from ..common.url import join_url, maybe_unquote
from ..core.package_cache_data import PackageCacheData
from ..exceptions import (CondaDependencyError, CondaHTTPError, CondaUpgradeError,
NotWritableError, UnavailableInvalidChannel)
NotWritableError, UnavailableInvalidChannel, ProxyError)
from ..gateways.connection import (ConnectionError, HTTPError, InsecureRequestWarning,
InvalidSchema, SSLError)
InvalidSchema, SSLError, RequestsProxyError)
from ..gateways.connection.session import CondaSession
from ..gateways.disk import mkdir_p, mkdir_p_sudo_safe
from ..gateways.disk.delete import rm_rf
Expand Down Expand Up @@ -431,6 +431,9 @@ def fetch_repodata_remote_request(url, etag, mod_stamp):
log.debug(stringify(resp, content_max_len=256))
resp.raise_for_status()

except RequestsProxyError:
raise ProxyError() # see #3962

except InvalidSchema as e:
if 'SOCKS' in text_type(e):
message = dals("""
Expand Down
9 changes: 7 additions & 2 deletions conda/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,13 @@ def __init__(self, message, **kwargs):

class ProxyError(CondaError):
def __init__(self, message):
msg = '%s' % message
super(ProxyError, self).__init__(msg)
message = dals("""
Conda cannot proceed due to an error in your proxy configuration.
Check for typos and other configuration errors in any '.netrc' file in your home directory,
any environment variables ending in '_PROXY', and any other system-wide proxy
configuration settings.
""")
super(ProxyError, self).__init__(message)


class CondaIOError(CondaError, IOError):
Expand Down
6 changes: 4 additions & 2 deletions conda/gateways/connection/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def should_bypass_proxies_patched(should_bypass_proxies_func, url, no_proxy=None
from requests.adapters import BaseAdapter, HTTPAdapter
from requests.auth import AuthBase, _basic_auth_str
from requests.cookies import extract_cookies_to_jar
from requests.exceptions import InvalidSchema, SSLError
from requests.exceptions import InvalidSchema, SSLError, ProxyError as RequestsProxyError
from requests.hooks import dispatch_hook
from requests.models import Response
from requests.packages.urllib3.exceptions import InsecureRequestWarning
Expand All @@ -39,7 +39,8 @@ def should_bypass_proxies_patched(should_bypass_proxies_func, url, no_proxy=None
from pip._vendor.requests.adapters import BaseAdapter, HTTPAdapter
from pip._vendor.requests.auth import AuthBase, _basic_auth_str
from pip._vendor.requests.cookies import extract_cookies_to_jar
from pip._vendor.requests.exceptions import InvalidSchema, SSLError
from pip._vendor.requests.exceptions import (InvalidSchema, SSLError,
ProxyError as RequestsProxyError)
from pip._vendor.requests.hooks import dispatch_hook
from pip._vendor.requests.models import Response
from pip._vendor.requests.packages.urllib3.exceptions import InsecureRequestWarning
Expand Down Expand Up @@ -69,3 +70,4 @@ def should_bypass_proxies_patched(should_bypass_proxies_func, url, no_proxy=None
InvalidSchema = InvalidSchema
SSLError = SSLError
InsecureRequestWarning = InsecureRequestWarning
RequestsProxyError = RequestsProxyError
8 changes: 6 additions & 2 deletions conda/gateways/connection/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import tempfile
import warnings

from . import ConnectionError, HTTPError, InsecureRequestWarning, InvalidSchema, SSLError
from . import (ConnectionError, HTTPError, InsecureRequestWarning, InvalidSchema,
SSLError, RequestsProxyError)
from .session import CondaSession
from ..disk.delete import rm_rf
from ... import CondaError
Expand All @@ -19,7 +20,7 @@
from ...common.compat import text_type
from ...common.io import time_recorder
from ...exceptions import (BasicClobberError, CondaDependencyError, CondaHTTPError,
ChecksumMismatchError, maybe_raise)
ChecksumMismatchError, maybe_raise, ProxyError)

log = getLogger(__name__)

Expand Down Expand Up @@ -107,6 +108,9 @@ def download(url, target_full_path, sha256sum=None, md5sum=None, progress_update
reference_hash))
raise ChecksumMismatchError(url, target_full_path, reference_hash, actual_hash)

except RequestsProxyError:
raise ProxyError() # see #3962

except InvalidSchema as e:
if 'SOCKS' in text_type(e):
message = dals("""
Expand Down

0 comments on commit 9208a96

Please sign in to comment.