Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
1e456c72
S
Serving
项目概览
PaddlePaddle
/
Serving
大约 1 年 前同步成功
通知
186
Star
833
Fork
253
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
105
列表
看板
标记
里程碑
合并请求
10
Wiki
2
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Serving
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
105
Issue
105
列表
看板
标记
里程碑
合并请求
10
合并请求
10
Pages
分析
分析
仓库分析
DevOps
Wiki
2
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
1e456c72
编写于
4月 02, 2020
作者:
B
barrierye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bug in FTP monitor
上级
156854a3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
46 addition
and
22 deletion
+46
-22
python/paddle_serving_server/monitor.py
python/paddle_serving_server/monitor.py
+46
-22
未找到文件。
python/paddle_serving_server/monitor.py
浏览文件 @
1e456c72
...
@@ -83,18 +83,26 @@ class Monitor(object):
...
@@ -83,18 +83,26 @@ class Monitor(object):
if
self
.
_local_tmp_path
is
None
:
if
self
.
_local_tmp_path
is
None
:
raise
Exception
(
'local_tmp_path not set.'
)
raise
Exception
(
'local_tmp_path not set.'
)
def
_decompress_model_file
(
local_tmp_path
,
model_name
,
unpacked_filename
):
def
_decompress_model_file
(
self
,
local_tmp_path
,
model_name
,
unpacked_filename
):
import
sys
print
(
unpacked_filename
)
sys
.
stdout
.
flush
()
if
unpacked_filename
is
None
:
if
unpacked_filename
is
None
:
return
model_name
return
model_name
tar_model_path
=
os
.
path
.
join
(
local_tmp_path
,
model_name
)
tar_model_path
=
os
.
path
.
join
(
local_tmp_path
,
model_name
)
print
(
tar_model_path
)
sys
.
stdout
.
flush
()
if
not
tarfile
.
is_tarfile
(
tar_model_path
):
if
not
tarfile
.
is_tarfile
(
tar_model_path
):
raise
Exception
(
raise
Exception
(
'the model({}) of remote production is not a tar packaged file type.'
.
'the model({}) of remote production is not a tar packaged file type.'
.
format
(
tar_model_path
))
format
(
tar_model_path
))
try
:
try
:
tar
=
tarfile
.
open
(
tar_model_path
)
tar
=
tarfile
.
open
(
tar_model_path
)
tar
.
extractall
(
path
=
os
.
join
(
local_tmp_path
)
)
tar
.
extractall
(
local_tmp_path
)
tar
.
close
()
tar
.
close
()
print
(
'ok'
)
sys
.
stdout
.
flush
()
except
:
except
:
raise
Exception
(
raise
Exception
(
'Decompressing failed, please check your permission of {} or disk space left.'
.
'Decompressing failed, please check your permission of {} or disk space left.'
.
...
@@ -256,33 +264,49 @@ class FTPMonitor(Monitor):
...
@@ -256,33 +264,49 @@ class FTPMonitor(Monitor):
except
ftplib
.
error_perm
:
except
ftplib
.
error_perm
:
return
[
False
,
None
]
return
[
False
,
None
]
def
_download_remote_file
(
self
,
remote_path
,
remote_filename
,
local_tmp_path
,
overwrite
=
True
):
local_fullpath
=
os
.
path
.
join
(
local_tmp_path
,
remote_filename
)
if
not
overwrite
and
os
.
path
.
isfile
(
fullpath
):
return
else
:
with
open
(
local_fullpath
,
'wb'
)
as
f
:
self
.
_ftp
.
cwd
(
remote_path
)
self
.
_ftp
.
retrbinary
(
'RETR {}'
.
format
(
remote_filename
),
f
.
write
)
def
_download_remote_files
(
self
,
def
_download_remote_files
(
self
,
remote_path
,
remote_path
,
remote_dirname
,
remote_dirname
,
local_tmp_path
,
local_tmp_path
,
overwrite
=
True
):
overwrite
=
True
):
local_dirpath
=
os
.
path
.
join
(
local_tmp_path
,
remote_dirname
)
import
ftplib
if
not
os
.
path
.
exists
(
local_dirpath
):
os
.
mkdir
(
local_dirpath
)
remote_dirpath
=
os
.
path
.
join
(
remote_path
,
remote_dirname
)
remote_dirpath
=
os
.
path
.
join
(
remote_path
,
remote_dirname
)
output
=
[]
# Check whether remote_dirpath is a file or a folder
self
.
_ftp
.
cwd
(
remote_dirpath
)
try
:
self
.
_ftp
.
dir
(
output
.
append
)
self
.
_ftp
.
cwd
(
remote_dirpath
)
for
line
in
output
:
[
attr
,
_
,
_
,
_
,
_
,
_
,
_
,
_
,
name
]
=
line
.
split
()
local_dirpath
=
os
.
path
.
join
(
local_tmp_path
,
remote_dirname
)
if
attr
[
0
]
==
'd'
:
if
not
os
.
path
.
exists
(
local_dirpath
):
self
.
_download_remote_files
(
os
.
mkdir
(
local_dirpath
)
os
.
path
.
join
(
remote_path
,
remote_dirname
),
name
,
os
.
path
.
join
(
local_tmp_path
,
remote_dirname
),
overwrite
)
output
=
[]
else
:
self
.
_ftp
.
dir
(
output
.
append
)
fullpath
=
os
.
path
.
join
(
local_tmp_path
,
remote_dirname
,
name
)
for
line
in
output
:
if
not
overwrite
and
os
.
path
.
isfile
(
fullpath
):
[
attr
,
_
,
_
,
_
,
_
,
_
,
_
,
_
,
name
]
=
line
.
split
()
continue
if
attr
[
0
]
==
'd'
:
self
.
_download_remote_files
(
os
.
path
.
join
(
remote_path
,
remote_dirname
),
name
,
os
.
path
.
join
(
local_tmp_path
,
remote_dirname
),
overwrite
)
else
:
else
:
with
open
(
fullpath
,
'wb'
)
as
f
:
self
.
_download_remote_file
(
remote_dirname
,
name
,
self
.
_ftp
.
cwd
(
remote_dirpath
)
local_tmp_path
,
overwrite
)
self
.
_ftp
.
retrbinary
(
'RETR {}'
.
format
(
name
),
f
.
write
)
except
ftplib
.
error_perm
:
self
.
_download_remote_file
(
remote_path
,
remote_dirname
,
local_tmp_path
,
overwrite
)
return
def
_pull_remote_dir
(
self
,
remote_path
,
dirname
,
local_tmp_path
):
def
_pull_remote_dir
(
self
,
remote_path
,
dirname
,
local_tmp_path
):
self
.
_download_remote_files
(
self
.
_download_remote_files
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录