Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
d4f06b3e
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,发现更多精彩内容 >>
提交
d4f06b3e
编写于
1月 18, 2019
作者:
S
sangoh.hong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
improved server list sorting.
上级
61dbe609
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
25 addition
and
24 deletion
+25
-24
glances/outputs/glances_curses_browser.py
glances/outputs/glances_curses_browser.py
+25
-24
未找到文件。
glances/outputs/glances_curses_browser.py
浏览文件 @
d4f06b3e
...
@@ -62,7 +62,7 @@ class GlancesCursesBrowser(_GlancesCurses):
...
@@ -62,7 +62,7 @@ class GlancesCursesBrowser(_GlancesCurses):
self
.
_page_max_lines
=
0
self
.
_page_max_lines
=
0
self
.
is_end
=
False
self
.
is_end
=
False
self
.
_
sort_order_list
=
Non
e
self
.
_
revesed_sorting
=
Fals
e
self
.
_stats_list
=
None
self
.
_stats_list
=
None
@
property
@
property
...
@@ -104,19 +104,21 @@ class GlancesCursesBrowser(_GlancesCurses):
...
@@ -104,19 +104,21 @@ class GlancesCursesBrowser(_GlancesCurses):
return
result
return
result
def
_sort_by_status
(
self
,
item
):
def
_get_stats
(
self
,
stats
):
key
=
item
[
'status'
]
stats_list
=
None
if
key
==
'ONLINE'
:
if
self
.
_stats_list
is
not
None
:
return
self
.
_sort_order_list
[
0
]
stats_list
=
self
.
_stats_list
elif
key
==
'SNMP'
:
stats_list
.
sort
(
reverse
=
self
.
_revesed_sorting
,
return
self
.
_sort_order_list
[
1
]
key
=
lambda
x
:
{
'UNKNOWN'
:
0
,
elif
key
==
'PROTECTED'
:
'OFFLINE'
:
1
,
return
self
.
_sort_order_list
[
2
]
'PROTECTED'
:
2
,
elif
key
==
'OFFLINE'
:
'SNMP'
:
3
,
return
self
.
_sort_order_list
[
3
]
'ONLINE'
:
4
}.
get
(
x
[
'status'
],
99
))
elif
key
==
'UNKNOWN'
:
else
:
return
self
.
_sort_order_list
[
4
]
stats_list
=
stats
return
stats_list
def
cursor_up
(
self
,
stats
):
def
cursor_up
(
self
,
stats
):
"""Set the cursor to position N-1 in the list."""
"""Set the cursor to position N-1 in the list."""
if
0
<=
self
.
cursor_position
-
1
:
if
0
<=
self
.
cursor_position
-
1
:
...
@@ -192,15 +194,14 @@ class GlancesCursesBrowser(_GlancesCurses):
...
@@ -192,15 +194,14 @@ class GlancesCursesBrowser(_GlancesCurses):
self
.
cursor_pagedown
(
stats
)
self
.
cursor_pagedown
(
stats
)
logger
.
debug
(
"PageDown: Server {}/{} pages"
.
format
(
self
.
_current_page
+
1
,
self
.
_page_max
))
logger
.
debug
(
"PageDown: Server {}/{} pages"
.
format
(
self
.
_current_page
+
1
,
self
.
_page_max
))
elif
self
.
pressedkey
==
ord
(
'1'
):
elif
self
.
pressedkey
==
ord
(
'1'
):
self
.
_sort_order_list
=
None
self
.
_stats_list
=
None
self
.
_stats_list
=
None
refresh
=
True
refresh
=
True
elif
self
.
pressedkey
==
ord
(
'2'
):
elif
self
.
pressedkey
==
ord
(
'2'
):
self
.
_
sort_order_list
=
[
0
,
1
,
2
,
3
,
4
]
self
.
_
revesed_sorting
=
False
self
.
_stats_list
=
stats
.
copy
()
self
.
_stats_list
=
stats
.
copy
()
refresh
=
True
refresh
=
True
elif
self
.
pressedkey
==
ord
(
'3'
):
elif
self
.
pressedkey
==
ord
(
'3'
):
self
.
_
sort_order_list
=
[
4
,
3
,
2
,
1
,
0
]
self
.
_
revesed_sorting
=
True
self
.
_stats_list
=
stats
.
copy
()
self
.
_stats_list
=
stats
.
copy
()
refresh
=
True
refresh
=
True
...
@@ -292,6 +293,12 @@ class GlancesCursesBrowser(_GlancesCurses):
...
@@ -292,6 +293,12 @@ class GlancesCursesBrowser(_GlancesCurses):
msg
,
msg
,
screen_x
-
x
,
screen_x
-
x
,
self
.
colors_list
[
'TITLE'
])
self
.
colors_list
[
'TITLE'
])
msg
=
'{}'
.
format
(
self
.
_get_status_count
(
stats
))
self
.
term_window
.
addnstr
(
y
+
1
,
x
,
msg
,
screen_x
-
x
)
if
stats_len
>
stats_max
and
screen_y
>
2
:
if
stats_len
>
stats_max
and
screen_y
>
2
:
msg
=
'{} servers displayed.({}/{}) {}'
.
format
(
self
.
get_pagelines
(
stats
),
msg
=
'{} servers displayed.({}/{}) {}'
.
format
(
self
.
get_pagelines
(
stats
),
self
.
_current_page
+
1
,
self
.
_current_page
+
1
,
...
@@ -339,13 +346,7 @@ class GlancesCursesBrowser(_GlancesCurses):
...
@@ -339,13 +346,7 @@ class GlancesCursesBrowser(_GlancesCurses):
# Set the cursor position to the latest item
# Set the cursor position to the latest item
self
.
cursor
=
len
(
stats
)
-
1
self
.
cursor
=
len
(
stats
)
-
1
stats_list
=
None
stats_list
=
self
.
_get_stats
(
stats
)
if
self
.
_sort_order_list
is
not
None
and
self
.
_stats_list
is
not
None
:
stats_list
=
self
.
_stats_list
stats_list
.
sort
(
key
=
self
.
_sort_by_status
)
else
:
stats_list
=
stats
start_line
=
self
.
_page_max_lines
*
self
.
_current_page
start_line
=
self
.
_page_max_lines
*
self
.
_current_page
end_line
=
start_line
+
self
.
get_pagelines
(
stats_list
)
end_line
=
start_line
+
self
.
get_pagelines
(
stats_list
)
current_page
=
stats_list
[
start_line
:
end_line
]
current_page
=
stats_list
[
start_line
:
end_line
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录