Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
14350c5f
G
glances
项目概览
蜕变的菜鸟
/
glances
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
glances
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
14350c5f
编写于
5月 19, 2019
作者:
N
nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
A simple hask to disable plugin if a an error occurs on load
上级
5bd4d587
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
32 addition
and
22 deletion
+32
-22
glances/amps/glances_amp.py
glances/amps/glances_amp.py
+2
-1
glances/outputs/glances_curses.py
glances/outputs/glances_curses.py
+17
-15
glances/stats.py
glances/stats.py
+13
-6
未找到文件。
glances/amps/glances_amp.py
浏览文件 @
14350c5f
...
...
@@ -32,7 +32,7 @@ The return string is a string with one or more line (\n between lines).
If the *one_line* var is true then the AMP will be displayed in one line.
"""
from
glances.compat
import
u
from
glances.compat
import
u
,
b
,
n
,
nativestr
from
glances.timer
import
Timer
from
glances.logger
import
logger
...
...
@@ -180,6 +180,7 @@ class GlancesAmp(object):
"""Store the result (string) into the result key of the AMP
if one_line is true then replace
\n
by separator
"""
# self.configs['result'] = unicode(result, 'utf-8').encode('utf-8', errors='replace')
if
self
.
one_line
():
self
.
configs
[
'result'
]
=
str
(
result
).
replace
(
'
\n
'
,
separator
)
else
:
...
...
glances/outputs/glances_curses.py
浏览文件 @
14350c5f
...
...
@@ -733,11 +733,11 @@ class _GlancesCurses(object):
if
self
.
args
.
disable_left_sidebar
:
return
for
s
in
self
.
_left_sidebar
:
if
((
hasattr
(
self
.
args
,
'enable_'
+
s
)
or
hasattr
(
self
.
args
,
'disable_'
+
s
))
and
s
in
stat_display
):
for
p
in
self
.
_left_sidebar
:
if
((
hasattr
(
self
.
args
,
'enable_'
+
p
)
or
hasattr
(
self
.
args
,
'disable_'
+
p
))
and
s
in
stat_display
):
self
.
new_line
()
self
.
display_plugin
(
stat_display
[
s
])
self
.
display_plugin
(
stat_display
[
p
])
def
__display_right
(
self
,
stat_display
):
"""Display the right sidebar in the Curses interface.
...
...
@@ -754,17 +754,19 @@ class _GlancesCurses(object):
# Display right sidebar
self
.
new_column
()
for
p
in
self
.
_right_sidebar
:
if
p
not
in
p
:
# Catch for issue #1470
continue
self
.
new_line
()
if
p
==
'processlist'
:
self
.
display_plugin
(
stat_display
[
'processlist'
],
display_optional
=
(
self
.
screen
.
getmaxyx
()[
1
]
>
102
),
display_additional
=
(
not
MACOS
),
max_y
=
(
self
.
screen
.
getmaxyx
()[
0
]
-
self
.
get_stats_display_height
(
stat_display
[
'alert'
])
-
2
))
else
:
self
.
display_plugin
(
stat_display
[
p
])
if
((
hasattr
(
self
.
args
,
'enable_'
+
p
)
or
hasattr
(
self
.
args
,
'disable_'
+
p
))
and
p
in
stat_display
):
if
p
not
in
p
:
# Catch for issue #1470
continue
self
.
new_line
()
if
p
==
'processlist'
:
self
.
display_plugin
(
stat_display
[
'processlist'
],
display_optional
=
(
self
.
screen
.
getmaxyx
()[
1
]
>
102
),
display_additional
=
(
not
MACOS
),
max_y
=
(
self
.
screen
.
getmaxyx
()[
0
]
-
self
.
get_stats_display_height
(
stat_display
[
'alert'
])
-
2
))
else
:
self
.
display_plugin
(
stat_display
[
p
])
def
display_popup
(
self
,
message
,
size_x
=
None
,
size_y
=
None
,
...
...
glances/stats.py
浏览文件 @
14350c5f
...
...
@@ -117,16 +117,22 @@ class GlancesStats(object):
self
.
_plugins
[
name
]
=
plugin
.
Plugin
(
args
=
args
,
config
=
config
)
else
:
self
.
_plugins
[
name
]
=
plugin
.
Plugin
(
args
=
args
)
# Set the disable_<name> to False by default
if
self
.
args
is
not
None
:
setattr
(
self
.
args
,
'disable_'
+
name
,
getattr
(
self
.
args
,
'disable_'
+
name
,
False
))
except
Exception
as
e
:
# If a plugin can not be lo
g
, display a critical message
# If a plugin can not be lo
aded
, display a critical message
# on the console but do not crash
logger
.
critical
(
"Error while initializing the {} plugin ({})"
.
format
(
name
,
e
))
logger
.
error
(
traceback
.
format_exc
())
# Disable the plugin
if
args
is
not
None
:
setattr
(
args
,
'disable_'
+
name
,
False
)
else
:
# Set the disable_<name> to False by default
if
args
is
not
None
:
setattr
(
args
,
'disable_'
+
name
,
getattr
(
args
,
'disable_'
+
name
,
False
))
def
load_plugins
(
self
,
args
=
None
):
"""Load all plugins in the 'plugins' folder."""
...
...
@@ -140,6 +146,7 @@ class GlancesStats(object):
# Log plugins list
logger
.
debug
(
"Active plugins list: {}"
.
format
(
self
.
getPluginsList
()))
logger
.
critical
(
">>> Active plugins list: {}"
.
format
(
self
.
getPluginsList
()))
def
load_exports
(
self
,
args
=
None
):
"""Load all export modules in the 'exports' folder."""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录