Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
a951a6cd
A
avocado
项目概览
openeuler
/
avocado
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
avocado
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a951a6cd
编写于
4月 14, 2016
作者:
L
Lukáš Doktor
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1124 from clebergnu/plugin_improvements
Plugin Improvements
上级
76627c00
d4edc34a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
41 addition
and
45 deletion
+41
-45
avocado/core/app.py
avocado/core/app.py
+2
-18
avocado/core/output.py
avocado/core/output.py
+20
-0
avocado/plugins/base.py
avocado/plugins/base.py
+2
-8
avocado/plugins/plugins.py
avocado/plugins/plugins.py
+17
-19
未找到文件。
avocado/core/app.py
浏览文件 @
a951a6cd
...
...
@@ -16,14 +16,12 @@
The core Avocado application.
"""
import
logging
import
os
import
signal
from
.parser
import
Parser
from
.
import
output
from
.output
import
STD_OUTPUT
from
.settings
import
settings
from
.dispatcher
import
CLIDispatcher
from
.dispatcher
import
CLICmdDispatcher
...
...
@@ -46,7 +44,8 @@ class AvocadoApp(object):
try
:
self
.
cli_dispatcher
=
CLIDispatcher
()
self
.
cli_cmd_dispatcher
=
CLICmdDispatcher
()
self
.
_print_plugin_failures
()
output
.
log_plugin_failures
(
self
.
cli_dispatcher
.
load_failures
+
self
.
cli_cmd_dispatcher
.
load_failures
)
self
.
parser
.
start
()
if
self
.
cli_cmd_dispatcher
.
extensions
:
self
.
cli_cmd_dispatcher
.
map_method
(
'configure'
,
self
.
parser
)
...
...
@@ -59,21 +58,6 @@ class AvocadoApp(object):
finally
:
output
.
reconfigure
(
self
.
parser
.
args
)
def
_print_plugin_failures
(
self
):
failures
=
(
self
.
cli_dispatcher
.
load_failures
+
self
.
cli_cmd_dispatcher
.
load_failures
)
if
failures
:
log
=
logging
.
getLogger
(
"avocado.app"
)
msg_fmt
=
'Failed to load plugin from module "%s": %s'
silenced
=
settings
.
get_value
(
'plugins'
,
'skip_broken_plugin_notification'
,
list
,
[])
for
failure
in
failures
:
if
failure
[
0
].
module_name
in
silenced
:
continue
log
.
error
(
msg_fmt
,
failure
[
0
].
module_name
,
failure
[
1
].
__repr__
())
def
run
(
self
):
try
:
try
:
...
...
avocado/core/output.py
浏览文件 @
a951a6cd
...
...
@@ -671,3 +671,23 @@ class Throbber(object):
result
=
self
.
MOVES
[
self
.
position
]
self
.
_update_position
()
return
result
def
log_plugin_failures
(
failures
):
"""
Log in the application UI failures to load a set of plugins
:param failures: a list of load failures, usually comming from a
:class:`avocado.core.dispatcher.Dispatcher`
attribute `load_failures`
"""
log
=
logging
.
getLogger
(
"avocado.app"
)
msg_fmt
=
'Failed to load plugin from module "%s": %s'
silenced
=
settings
.
get_value
(
'plugins'
,
'skip_broken_plugin_notification'
,
list
,
[])
for
failure
in
failures
:
if
failure
[
0
].
module_name
in
silenced
:
continue
log
.
error
(
msg_fmt
,
failure
[
0
].
module_name
,
failure
[
1
].
__repr__
())
avocado/plugins/base.py
浏览文件 @
a951a6cd
...
...
@@ -18,6 +18,8 @@ import abc
class
Plugin
(
object
):
__metaclass__
=
abc
.
ABCMeta
"""
Base for all plugins
"""
...
...
@@ -31,10 +33,6 @@ class CLI(Plugin):
Plugins that want to add extra options to the core command line application
or to sub commands should use the 'avocado.plugins.cli' namespace.
"""
__metaclass__
=
abc
.
ABCMeta
def
__init__
(
self
):
super
(
CLI
,
self
).
__init__
()
@
abc
.
abstractmethod
def
configure
(
self
,
parser
):
...
...
@@ -63,13 +61,9 @@ class CLICmd(Plugin):
Plugins that want to add extensions to the run command should use the
'avocado.plugins.cli.cmd' namespace.
"""
__metaclass__
=
abc
.
ABCMeta
name
=
None
description
=
None
def
__init__
(
self
):
super
(
CLICmd
,
self
).
__init__
()
def
configure
(
self
,
parser
):
"""
Lets the extension add command line options and do early configuration
...
...
avocado/plugins/plugins.py
浏览文件 @
a951a6cd
...
...
@@ -41,22 +41,20 @@ class Plugins(CLICmd):
def
run
(
self
,
args
):
log
=
logging
.
getLogger
(
"avocado.app"
)
cli_cmds
=
dispatcher
.
CLICmdDispatcher
()
msg
=
'Plugins that add new commands (avocado.plugins.cli.cmd):'
log
.
info
(
msg
)
plugin_matrix
=
[]
for
plugin
in
sorted
(
cli_cmds
):
plugin_matrix
.
append
((
plugin
.
name
,
plugin
.
obj
.
description
))
for
line
in
astring
.
iter_tabular_output
(
plugin_matrix
):
log
.
debug
(
line
)
msg
=
'Plugins that add new options to commands (avocado.plugins.cli):'
cli
=
dispatcher
.
CLIDispatcher
()
log
.
info
(
msg
)
plugin_matrix
=
[]
for
plugin
in
sorted
(
cli
):
plugin_matrix
.
append
((
plugin
.
name
,
plugin
.
obj
.
description
))
for
line
in
astring
.
iter_tabular_output
(
plugin_matrix
):
log
.
debug
(
line
)
plugin_types
=
[
(
dispatcher
.
CLICmdDispatcher
(),
'Plugins that add new commands (avocado.plugins.cli.cmd):'
),
(
dispatcher
.
CLIDispatcher
(),
'Plugins that add new options to commands (avocado.plugins.cli):'
)
]
for
plugins_active
,
msg
in
plugin_types
:
log
.
info
(
msg
)
plugin_matrix
=
[]
for
plugin
in
sorted
(
plugins_active
):
plugin_matrix
.
append
((
plugin
.
name
,
plugin
.
obj
.
description
))
if
not
plugin_matrix
:
log
.
debug
(
"(No active plugin)"
)
else
:
for
line
in
astring
.
iter_tabular_output
(
plugin_matrix
):
log
.
debug
(
line
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录