Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
66aa8c45
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看板
提交
66aa8c45
编写于
9月 12, 2019
作者:
S
shenyuhan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify hub config
上级
0886e702
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
17 addition
and
37 deletion
+17
-37
paddlehub/commands/config.py
paddlehub/commands/config.py
+11
-32
paddlehub/common/logger.py
paddlehub/common/logger.py
+6
-5
未找到文件。
paddlehub/commands/config.py
浏览文件 @
66aa8c45
...
...
@@ -67,25 +67,14 @@ class ConfigCommand(BaseCommand):
print
(
"Set success! The current configuration is shown below."
)
print
(
json
.
dumps
(
config
,
indent
=
4
))
@
staticmethod
def
show_server_url
():
with
open
(
os
.
path
.
join
(
CONF_HOME
,
"config.json"
),
"r"
)
as
fp
:
config
=
json
.
load
(
fp
)
print
(
config
[
"server_url"
])
@
staticmethod
def
show_log_level
():
with
open
(
os
.
path
.
join
(
CONF_HOME
,
"config.json"
),
"r"
)
as
fp
:
print
(
json
.
load
(
fp
)[
"log_level"
])
@
staticmethod
def
set_log_level
(
level
):
level
=
str
(
level
).
upper
()
if
level
not
in
[
"CRITICAL"
,
"FATAL"
,
"ERROR"
,
"WARN"
,
"WARNING"
,
"INFO"
,
"DEBUG"
,
"NOTSET"
"NOLOG"
,
"DEBUG"
,
"INFO"
,
"WARNING"
,
"ERROR"
,
"CRITICAL"
]:
print
(
"Allowed values include: "
"
CRITICAL, FATAL, ERROR, WARN, WARNING, INFO, DEBUG, NOTSET
"
)
"
NOLOG, DEBUG, INFO, WARNING, ERROR, CRITICAL
"
)
return
with
open
(
os
.
path
.
join
(
CONF_HOME
,
"config.json"
),
"r"
)
as
fp
:
current_config
=
json
.
load
(
fp
)
...
...
@@ -97,19 +86,15 @@ class ConfigCommand(BaseCommand):
@
staticmethod
def
show_help
():
str
=
"config <option>
<value>
\n
"
str
=
"config <option>
\n
"
str
+=
"
\t
Show hub server config without any option.
\n
"
str
+=
"option:
\n
"
str
+=
"reset
\n
"
str
+=
"
\t
Reset config as default.
\n
"
str
+=
"server
\n
"
str
+=
"
\t
Show server url.
\n
"
str
+=
"server [URL]
\n
"
str
+=
"server==[URL]
\n
"
str
+=
"
\t
Set hub server url as [URL].
\n
"
str
+=
"log
\n
"
str
+=
"
\t
Show log level.
\n
"
str
+=
"log [LEVEL]
\n
"
str
+=
"
\t
Set log level as [LEVEL:CRITICAL, FATAL, ERROR, WARN, WARNING, INFO, DEBUG, NOTSET].
\n
"
str
+=
"log==[LEVEL]
\n
"
str
+=
"
\t
Set log level as [LEVEL:NOLOG, DEBUG, INFO, WARNING, ERROR, CRITICAL].
\n
"
print
(
str
)
def
execute
(
self
,
argv
):
...
...
@@ -118,16 +103,10 @@ class ConfigCommand(BaseCommand):
ConfigCommand
.
show_config
()
elif
args
.
option
==
"reset"
:
ConfigCommand
.
set_config
(
default_server_config
)
elif
args
.
option
==
"server"
:
if
args
.
value
is
not
None
:
ConfigCommand
.
set_server_url
(
args
.
value
)
else
:
ConfigCommand
.
show_server_url
()
elif
args
.
option
==
"log"
:
if
args
.
value
is
not
None
:
ConfigCommand
.
set_log_level
(
args
.
value
)
else
:
ConfigCommand
.
show_log_level
()
elif
args
.
option
.
startswith
(
"server=="
):
ConfigCommand
.
set_server_url
(
args
.
option
.
split
(
"=="
)[
1
])
elif
args
.
option
.
startswith
(
"log=="
):
ConfigCommand
.
set_log_level
(
args
.
option
.
split
(
"=="
)[
1
])
else
:
ConfigCommand
.
show_help
()
return
True
...
...
paddlehub/common/logger.py
浏览文件 @
66aa8c45
...
...
@@ -39,12 +39,13 @@ class Logger(object):
self
.
handler
.
setFormatter
(
self
.
format
)
self
.
logger
.
addHandler
(
self
.
handler
)
if
not
os
.
path
.
exists
(
os
.
path
.
join
(
CONF_HOME
,
"config.json"
)):
self
.
logLevel
=
"DEBUG"
else
:
with
open
(
os
.
path
.
join
(
CONF_HOME
,
"config.json"
),
"r"
)
as
fp
:
self
.
logLevel
=
json
.
load
(
fp
).
get
(
"log_level"
,
"DEBUG"
)
self
.
logLevel
=
"DEBUG"
self
.
logger
.
setLevel
(
self
.
_get_logging_level
())
if
os
.
path
.
exists
(
os
.
path
.
join
(
CONF_HOME
,
"config.json"
)):
with
open
(
os
.
path
.
join
(
CONF_HOME
,
"config.json"
),
"r"
)
as
fp
:
level
=
json
.
load
(
fp
).
get
(
"log_level"
)
self
.
logLevel
=
level
self
.
setLevel
(
level
)
def
_is_no_log
(
self
):
return
self
.
getLevel
()
==
Logger
.
NOLOG
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录