Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
425a267b
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
大约 1 年 前同步成功
通知
282
Star
12117
Fork
2091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
200
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleHub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
200
Issue
200
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
425a267b
编写于
1月 04, 2019
作者:
Z
Zeyu Chen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove Chinese comments
上级
99835e3c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
8 addition
and
17 deletion
+8
-17
paddle_hub/downloader.py
paddle_hub/downloader.py
+8
-17
未找到文件。
paddle_hub/downloader.py
浏览文件 @
425a267b
...
@@ -11,8 +11,8 @@
...
@@ -11,8 +11,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
# coding=utf-8
# coding=utf-8
from
__future__
import
print_function
from
__future__
import
print_function
from
__future__
import
division
from
__future__
import
division
from
__future__
import
print_function
from
__future__
import
print_function
...
@@ -64,9 +64,9 @@ def download_and_uncompress(url, save_name=None):
...
@@ -64,9 +64,9 @@ def download_and_uncompress(url, save_name=None):
os
.
makedirs
(
dirname
)
os
.
makedirs
(
dirname
)
#TODO(ZeyuChen) add download md5 file to verify file completeness
#TODO(ZeyuChen) add download md5 file to verify file completeness
file_name
=
os
.
path
.
join
(
file_name
=
os
.
path
.
join
(
dirname
,
dirname
,
url
.
split
(
'/'
)[
-
1
]
url
.
split
(
'/'
)[
-
1
]
if
save_name
is
None
else
save_name
)
if
save_name
is
None
else
save_name
)
retry
=
0
retry
=
0
retry_limit
=
3
retry_limit
=
3
...
@@ -76,9 +76,8 @@ def download_and_uncompress(url, save_name=None):
...
@@ -76,9 +76,8 @@ def download_and_uncompress(url, save_name=None):
if
retry
<
retry_limit
:
if
retry
<
retry_limit
:
retry
+=
1
retry
+=
1
else
:
else
:
raise
RuntimeError
(
raise
RuntimeError
(
"Cannot download {0} within retry limit {1}"
.
"Cannot download {0} within retry limit {1}"
.
format
(
format
(
url
,
retry_limit
))
url
,
retry_limit
))
print
(
"Cache file %s not found, downloading %s"
%
(
file_name
,
url
))
print
(
"Cache file %s not found, downloading %s"
%
(
file_name
,
url
))
r
=
requests
.
get
(
url
,
stream
=
True
)
r
=
requests
.
get
(
url
,
stream
=
True
)
total_length
=
r
.
headers
.
get
(
'content-length'
)
total_length
=
r
.
headers
.
get
(
'content-length'
)
...
@@ -95,8 +94,8 @@ def download_and_uncompress(url, save_name=None):
...
@@ -95,8 +94,8 @@ def download_and_uncompress(url, save_name=None):
dl
+=
len
(
data
)
dl
+=
len
(
data
)
f
.
write
(
data
)
f
.
write
(
data
)
done
=
int
(
50
*
dl
/
total_length
)
done
=
int
(
50
*
dl
/
total_length
)
sys
.
stdout
.
write
(
sys
.
stdout
.
write
(
"
\r
[%s%s]"
%
(
'='
*
done
,
"
\r
[%s%s]"
%
(
'='
*
done
,
' '
*
(
50
-
done
)))
' '
*
(
50
-
done
)))
sys
.
stdout
.
flush
()
sys
.
stdout
.
flush
()
print
(
"file download completed!"
,
file_name
)
print
(
"file download completed!"
,
file_name
)
...
@@ -119,14 +118,6 @@ class TqdmProgress(tqdm):
...
@@ -119,14 +118,6 @@ class TqdmProgress(tqdm):
last_block
=
0
last_block
=
0
def
update_to
(
self
,
block_num
=
1
,
block_size
=
1
,
total_size
=
None
):
def
update_to
(
self
,
block_num
=
1
,
block_size
=
1
,
total_size
=
None
):
'''
block_num : int, optional
到目前为止传输的块 [default: 1].
block_size : int, optional
每个块的大小 (in tqdm units) [default: 1].
total_size : int, optional
文件总大小 (in tqdm units). 如果[default: None]保持不变.
'''
if
total_size
is
not
None
:
if
total_size
is
not
None
:
self
.
total
=
total_size
self
.
total
=
total_size
self
.
update
((
block_num
-
self
.
last_block
)
*
block_size
)
self
.
update
((
block_num
-
self
.
last_block
)
*
block_size
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录