Mercurial > repos > shellac > sam_consensus_v3
comparison env/lib/python3.9/site-packages/pip/_internal/network/xmlrpc.py @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author | shellac |
---|---|
date | Mon, 22 Mar 2021 18:12:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4f3585e2f14b |
---|---|
1 """xmlrpclib.Transport implementation | |
2 """ | |
3 | |
4 import logging | |
5 import urllib.parse | |
6 | |
7 # NOTE: XMLRPC Client is not annotated in typeshed as on 2017-07-17, which is | |
8 # why we ignore the type on this import | |
9 from pip._vendor.six.moves import xmlrpc_client # type: ignore | |
10 | |
11 from pip._internal.exceptions import NetworkConnectionError | |
12 from pip._internal.network.utils import raise_for_status | |
13 from pip._internal.utils.typing import MYPY_CHECK_RUNNING | |
14 | |
15 if MYPY_CHECK_RUNNING: | |
16 from typing import Dict | |
17 | |
18 from pip._internal.network.session import PipSession | |
19 | |
20 | |
21 logger = logging.getLogger(__name__) | |
22 | |
23 | |
24 class PipXmlrpcTransport(xmlrpc_client.Transport): | |
25 """Provide a `xmlrpclib.Transport` implementation via a `PipSession` | |
26 object. | |
27 """ | |
28 | |
29 def __init__(self, index_url, session, use_datetime=False): | |
30 # type: (str, PipSession, bool) -> None | |
31 super().__init__(use_datetime) | |
32 index_parts = urllib.parse.urlparse(index_url) | |
33 self._scheme = index_parts.scheme | |
34 self._session = session | |
35 | |
36 def request(self, host, handler, request_body, verbose=False): | |
37 # type: (str, str, Dict[str, str], bool) -> None | |
38 parts = (self._scheme, host, handler, None, None, None) | |
39 url = urllib.parse.urlunparse(parts) | |
40 try: | |
41 headers = {'Content-Type': 'text/xml'} | |
42 response = self._session.post(url, data=request_body, | |
43 headers=headers, stream=True) | |
44 raise_for_status(response) | |
45 self.verbose = verbose | |
46 return self.parse_response(response.raw) | |
47 except NetworkConnectionError as exc: | |
48 assert exc.response | |
49 logger.critical( | |
50 "HTTP error %s while getting %s", | |
51 exc.response.status_code, url, | |
52 ) | |
53 raise |