Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Python_Packaging_Authority
pip
提交
07e87126
P
pip
项目概览
镜像
/
Python_Packaging_Authority
/
pip
12 个月 前同步成功
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
pip
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
07e87126
编写于
7月 09, 2020
作者:
P
Prashant Sharma
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
reformat(pip/_internal): Resolve lint errors
上级
8c267e6e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
27 addition
and
9 deletion
+27
-9
src/pip/_internal/exceptions.py
src/pip/_internal/exceptions.py
+13
-6
src/pip/_internal/network/download.py
src/pip/_internal/network/download.py
+6
-1
src/pip/_internal/network/lazy_wheel.py
src/pip/_internal/network/lazy_wheel.py
+6
-2
src/pip/_internal/network/xmlrpc.py
src/pip/_internal/network/xmlrpc.py
+1
-0
tests/lib/requests_mocks.py
tests/lib/requests_mocks.py
+1
-0
未找到文件。
src/pip/_internal/exceptions.py
浏览文件 @
07e87126
...
...
@@ -9,9 +9,10 @@ from pip._vendor.six import iteritems
from
pip._internal.utils.typing
import
MYPY_CHECK_RUNNING
if
MYPY_CHECK_RUNNING
:
from
typing
import
Any
,
Optional
,
List
,
Dict
from
typing
import
Any
,
Optional
,
List
,
Dict
,
Text
from
pip._vendor.pkg_resources
import
Distribution
from
pip._vendor.requests.models
import
Response
,
Request
from
pip._vendor.six
import
PY3
from
pip._vendor.six.moves
import
configparser
...
...
@@ -102,18 +103,24 @@ class PreviousBuildDirError(PipError):
class
NetworkConnectionError
(
PipError
):
"""HTTP connection error"""
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
error_msg
,
response
=
None
,
request
=
None
):
# type: (Text, Response, Request) -> None
"""
Initialize NetworkConnectionError with `request` and `response`
objects.
"""
response
=
kwargs
.
pop
(
'response'
,
None
)
self
.
response
=
response
self
.
request
=
kwargs
.
pop
(
'request'
,
None
)
if
(
response
is
not
None
and
not
self
.
request
and
self
.
request
=
request
self
.
error_msg
=
error_msg
if
(
self
.
response
is
not
None
and
not
self
.
request
and
hasattr
(
response
,
'request'
)):
self
.
request
=
self
.
response
.
request
super
(
NetworkConnectionError
,
self
).
__init__
(
*
args
,
**
kwargs
)
super
(
NetworkConnectionError
,
self
).
__init__
(
error_msg
,
response
,
request
)
def
__str__
(
self
):
# type: () -> str
return
str
(
self
.
error_msg
)
class
InvalidWheelFilename
(
InstallationError
):
...
...
src/pip/_internal/network/download.py
浏览文件 @
07e87126
...
...
@@ -11,7 +11,11 @@ from pip._internal.cli.progress_bars import DownloadProgressProvider
from
pip._internal.exceptions
import
NetworkConnectionError
from
pip._internal.models.index
import
PyPI
from
pip._internal.network.cache
import
is_from_cache
from
pip._internal.network.utils
import
HEADERS
,
raise_for_status
,
response_chunks
from
pip._internal.network.utils
import
(
HEADERS
,
raise_for_status
,
response_chunks
,
)
from
pip._internal.utils.misc
import
(
format_size
,
redact_auth_from_url
,
...
...
@@ -165,6 +169,7 @@ class Downloader(object):
try
:
resp
=
_http_get_download
(
self
.
_session
,
link
)
except
NetworkConnectionError
as
e
:
assert
e
.
response
is
not
None
logger
.
critical
(
"HTTP error %s while getting %s"
,
e
.
response
.
status_code
,
link
)
...
...
src/pip/_internal/network/lazy_wheel.py
浏览文件 @
07e87126
...
...
@@ -10,7 +10,11 @@ from zipfile import BadZipfile, ZipFile
from
pip._vendor.requests.models
import
CONTENT_CHUNK_SIZE
from
pip._vendor.six.moves
import
range
from
pip._internal.network.utils
import
HEADERS
,
response_chunks
from
pip._internal.network.utils
import
(
HEADERS
,
raise_for_status
,
response_chunks
,
)
from
pip._internal.utils.typing
import
MYPY_CHECK_RUNNING
from
pip._internal.utils.wheel
import
pkg_resources_distribution_for_wheel
...
...
@@ -51,7 +55,7 @@ class LazyZipOverHTTP(object):
def
__init__
(
self
,
url
,
session
,
chunk_size
=
CONTENT_CHUNK_SIZE
):
# type: (str, PipSession, int) -> None
head
=
session
.
head
(
url
,
headers
=
HEADERS
)
head
.
raise_for_status
(
)
raise_for_status
(
head
)
assert
head
.
status_code
==
200
self
.
_session
,
self
.
_url
,
self
.
_chunk_size
=
session
,
url
,
chunk_size
self
.
_length
=
int
(
head
.
headers
[
'Content-Length'
])
...
...
src/pip/_internal/network/xmlrpc.py
浏览文件 @
07e87126
...
...
@@ -44,6 +44,7 @@ class PipXmlrpcTransport(xmlrpc_client.Transport):
self
.
verbose
=
verbose
return
self
.
parse_response
(
response
.
raw
)
except
NetworkConnectionError
as
exc
:
assert
exc
.
response
logger
.
critical
(
"HTTP error %s while getting %s"
,
exc
.
response
.
status_code
,
url
,
...
...
tests/lib/requests_mocks.py
浏览文件 @
07e87126
...
...
@@ -25,6 +25,7 @@ class MockResponse(object):
self
.
raw
=
FakeStream
(
contents
)
self
.
content
=
contents
self
.
request
=
None
self
.
reason
=
None
self
.
status_code
=
200
self
.
connection
=
None
self
.
url
=
None
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录