Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
58ad1e7d
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 搜索 >>
提交
58ad1e7d
编写于
12月 11, 2014
作者:
D
desbma
提交者:
Alessio Sergi
12月 12, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use operator.itemgetter instead of lambda when possible
上级
7cf0a319
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
15 addition
and
8 deletion
+15
-8
glances/core/glances_processes.py
glances/core/glances_processes.py
+3
-2
glances/plugins/glances_diskio.py
glances/plugins/glances_diskio.py
+3
-1
glances/plugins/glances_fs.py
glances/plugins/glances_fs.py
+3
-1
glances/plugins/glances_network.py
glances/plugins/glances_network.py
+2
-1
glances/plugins/glances_processlist.py
glances/plugins/glances_processlist.py
+4
-3
未找到文件。
glances/core/glances_processes.py
浏览文件 @
58ad1e7d
...
...
@@ -19,6 +19,7 @@
# Import Python lib
import
collections
import
operator
import
re
# Import psutil
...
...
@@ -709,11 +710,11 @@ class GlancesProcesses(object):
process
[
sortedby
][
3
],
reverse
=
sortedreverse
)
except
Exception
:
self
.
processlist
.
sort
(
key
=
lambda
process
:
process
[
'cpu_percent'
]
,
self
.
processlist
.
sort
(
key
=
operator
.
itemgetter
(
'cpu_percent'
)
,
reverse
=
sortedreverse
)
else
:
# Others sorts
self
.
processlist
.
sort
(
key
=
lambda
process
:
process
[
sortedby
]
,
self
.
processlist
.
sort
(
key
=
operator
.
itemgetter
(
sortedby
)
,
reverse
=
sortedreverse
)
return
self
.
processlist
glances/plugins/glances_diskio.py
浏览文件 @
58ad1e7d
...
...
@@ -19,6 +19,8 @@
"""Disk I/O plugin."""
import
operator
import
psutil
# Import Glances libs
...
...
@@ -134,7 +136,7 @@ class Plugin(GlancesPlugin):
msg
=
'{0:>7}'
.
format
(
_
(
"W/s"
))
ret
.
append
(
self
.
curse_add_line
(
msg
))
# Disk list (sorted by name)
for
i
in
sorted
(
self
.
stats
,
key
=
lambda
diskio
:
diskio
[
'disk_name'
]
):
for
i
in
sorted
(
self
.
stats
,
key
=
operator
.
itemgetter
(
'disk_name'
)
):
# Do not display hidden interfaces
if
self
.
is_hide
(
i
[
'disk_name'
]):
continue
...
...
glances/plugins/glances_fs.py
浏览文件 @
58ad1e7d
...
...
@@ -19,6 +19,8 @@
"""File system plugin."""
import
operator
import
psutil
from
glances.plugins.glances_plugin
import
GlancesPlugin
...
...
@@ -181,7 +183,7 @@ class Plugin(GlancesPlugin):
ret
.
append
(
self
.
curse_add_line
(
msg
))
# Disk list (sorted by name)
for
i
in
sorted
(
self
.
stats
,
key
=
lambda
fs
:
fs
[
'mnt_point'
]
):
for
i
in
sorted
(
self
.
stats
,
key
=
operator
.
itemgetter
(
'mnt_point'
)
):
# New line
ret
.
append
(
self
.
curse_new_line
())
if
i
[
'device_name'
]
==
''
or
i
[
'device_name'
]
==
'none'
:
...
...
glances/plugins/glances_network.py
浏览文件 @
58ad1e7d
...
...
@@ -20,6 +20,7 @@
"""Network plugin."""
import
base64
import
operator
import
psutil
...
...
@@ -223,7 +224,7 @@ class Plugin(GlancesPlugin):
msg
=
'{0:>7}'
.
format
(
_
(
"Tx/s"
))
ret
.
append
(
self
.
curse_add_line
(
msg
))
# Interface list (sorted by name)
for
i
in
sorted
(
self
.
stats
,
key
=
lambda
network
:
network
[
'interface_name'
]
):
for
i
in
sorted
(
self
.
stats
,
key
=
operator
.
itemgetter
(
'interface_name'
)
):
# Do not display hidden interfaces
if
self
.
is_hide
(
i
[
'interface_name'
]):
continue
...
...
glances/plugins/glances_processlist.py
浏览文件 @
58ad1e7d
...
...
@@ -20,6 +20,7 @@
"""Process list plugin."""
# Import sys libs
import
operator
import
os
from
datetime
import
timedelta
...
...
@@ -429,7 +430,7 @@ class Plugin(GlancesPlugin):
process
[
sortedby
][
3
],
reverse
=
sortedreverse
)
except
Exception
:
self
.
stats
.
sort
(
key
=
lambda
process
:
process
[
'cpu_percent'
]
,
self
.
stats
.
sort
(
key
=
operator
.
itemgetter
(
'cpu_percent'
)
,
reverse
=
sortedreverse
)
else
:
# Others sorts
...
...
@@ -437,10 +438,10 @@ class Plugin(GlancesPlugin):
self
.
stats
.
set_sorting
(
sortedby
,
sortedreverse
)
else
:
try
:
self
.
stats
.
sort
(
key
=
lambda
process
:
process
[
sortedby
]
,
self
.
stats
.
sort
(
key
=
operator
.
itemgetter
(
sortedby
)
,
reverse
=
sortedreverse
)
except
(
KeyError
,
TypeError
):
self
.
stats
.
sort
(
key
=
lambda
process
:
process
[
'name'
]
,
self
.
stats
.
sort
(
key
=
operator
.
itemgetter
(
'name'
)
,
reverse
=
False
)
return
self
.
stats
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录