Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
ea5586a8
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看板
提交
ea5586a8
编写于
3月 31, 2020
作者:
B
barrierye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bug in FTPMonitor
上级
9d24d14f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
29 deletion
+27
-29
python/paddle_serving_server/monitor.py
python/paddle_serving_server/monitor.py
+27
-29
未找到文件。
python/paddle_serving_server/monitor.py
浏览文件 @
ea5586a8
...
...
@@ -142,12 +142,12 @@ class AFSMonitor(Monitor):
''' AFS Monitor(by hadoop-client). '''
def
__init__
(
self
,
hadoop_bin
_path
,
hadoop_bin
,
hadoop_host
=
None
,
hadoop_ugi
=
None
,
interval
=
10
):
super
(
AFSMonitor
,
self
).
__init__
(
interval
)
self
.
_hadoop_bin
=
hadoop_bin
_path
self
.
_hadoop_bin
=
hadoop_bin
self
.
_hadoop_host
=
hadoop_host
self
.
_hadoop_ugi
=
hadoop_ugi
self
.
_cmd_prefix
=
'{} fs '
.
format
(
self
.
_hadoop_bin
)
...
...
@@ -217,45 +217,43 @@ class FTPMonitor(Monitor):
def
_exist_remote_file
(
self
,
path
,
filename
,
local_tmp_path
):
import
ftplib
try
:
filepath
=
os
.
path
.
join
(
path
,
filename
)
timestamp
=
self
.
_ftp
.
voidcmd
(
'MDTM {}'
.
format
(
file
path
))[
4
:].
strip
(
self
.
_ftp
.
cwd
(
path
)
timestamp
=
self
.
_ftp
.
voidcmd
(
'MDTM {}'
.
format
(
file
name
))[
4
:].
strip
(
)
return
[
True
,
timestamp
]
except
ftplib
.
error_perm
:
return
[
False
,
None
]
def
_download_remote_files
(
remote_path
,
def
_download_remote_files
(
self
,
remote_path
,
remote_dirname
,
local_tmp_path
,
overwrite
=
True
):
try
:
remote_dirpath
=
os
.
path
.
join
(
remote_path
,
remote_dirname
)
self
.
_ftp
.
cwd
(
remote_dirpath
)
os
.
mkdir
(
os
.
path
.
join
(
local_tmp_path
,
remote_dirname
))
except
OSError
:
# folder already exists at the local_tmp_path
pass
except
ftplib
.
error_perm
:
raise
Exception
(
'remote_path({}) not exist.'
.
format
(
remote_path
))
filelist
=
[
x
for
x
in
self_ftp
.
mlsd
()]
for
file
in
filelist
:
if
file
[
1
][
'type'
]
==
'file'
:
fullpath
=
os
.
path
.
join
(
local_tmp_path
,
remote_dirname
,
file
[
0
])
local_dirpath
=
os
.
path
.
join
(
local_tmp_path
,
remote_dirname
)
if
not
os
.
path
.
exists
(
local_dirpath
):
os
.
mkdir
(
local_dirpath
)
remote_dirpath
=
os
.
path
.
join
(
remote_path
,
remote_dirname
)
output
=
[]
self
.
_ftp
.
cwd
(
remote_dirpath
)
self
.
_ftp
.
dir
(
output
.
append
)
for
line
in
output
:
[
attr
,
_
,
_
,
_
,
_
,
_
,
_
,
_
,
name
]
=
line
.
split
()
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
:
fullpath
=
os
.
path
.
join
(
local_tmp_path
,
remote_dirname
,
name
)
if
not
overwrite
and
os
.
path
.
isfile
(
fullpath
):
continue
else
:
with
open
(
fullpath
,
'wb'
)
as
f
:
self
.
_ftp
.
retrbinary
(
'RETR '
+
file
[
0
],
f
.
write
)
elif
file
[
1
][
'type'
]
==
'dir'
:
self
.
_download_remote_files
(
os
.
path
.
join
(
remote_path
,
remote_dirname
),
file
[
0
],
os
.
path
.
join
(
local_tmp_path
,
remote_dirname
),
overwrite
)
else
:
print
(
'Unknown type: '
+
file
[
1
][
'type'
])
self
.
_ftp
.
cwd
(
remote_dirpath
)
self
.
_ftp
.
retrbinary
(
'RETR {}'
.
format
(
name
),
f
.
write
)
def
_pull_remote_dir
(
self
,
remote_path
,
dirname
,
local_tmp_path
):
self
.
_
exist_remote_file
(
self
.
_
download_remote_files
(
remote_path
,
dirname
,
local_tmp_path
,
overwrite
=
True
)
...
...
@@ -335,7 +333,7 @@ def parse_args():
"--ftp_password"
,
type
=
str
,
default
=
''
,
help
=
"Password of ftp"
)
# afs monitor
parser
.
add_argument
(
"--hadoop_bin
_path
"
,
type
=
str
,
help
=
"Hadoop_bin_path for afs"
)
"--hadoop_bin"
,
type
=
str
,
help
=
"Hadoop_bin_path for afs"
)
parser
.
add_argument
(
"--hadoop_host"
,
type
=
str
,
default
=
None
,
help
=
"Hadoop_host for afs"
)
parser
.
add_argument
(
...
...
@@ -365,7 +363,7 @@ def get_monitor(mtype):
return
GeneralMonitor
(
args
.
general_host
,
interval
=
args
.
interval
)
elif
mtype
==
'afs'
:
return
AFSMonitor
(
args
.
hadoop_bin
_path
,
args
.
hadoop_bin
,
args
.
hadoop_host
,
args
.
hadoop_ugi
,
interval
=
args
.
interval
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录