Merge pull request #1229 from Thomaash/develop

Implement number and alias aware diskio sorting
This commit is contained in:
Nicolas Hennion 2018-02-12 20:34:41 +01:00 committed by GitHub
commit f1bd304f79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,7 +19,7 @@
"""Disk I/O plugin.""" """Disk I/O plugin."""
import operator import re
from glances.timer import getTimeSinceLastUpdate from glances.timer import getTimeSinceLastUpdate
from glances.plugins.glances_plugin import GlancesPlugin from glances.plugins.glances_plugin import GlancesPlugin
@ -180,7 +180,10 @@ class Plugin(GlancesPlugin):
msg = '{:>7}'.format('W/s') msg = '{:>7}'.format('W/s')
ret.append(self.curse_add_line(msg)) ret.append(self.curse_add_line(msg))
# Disk list (sorted by name) # Disk list (sorted by name)
for i in sorted(self.stats, key=operator.itemgetter(self.get_key())): for i in sorted(self.stats, key=lambda stat: tuple(map(
lambda part: int(part) if part.isdigit() else part.lower(),
re.split(r"(\d+|\D+)", stat.get('alias') or stat['disk_name'])
))):
# Is there an alias for the disk name ? # Is there an alias for the disk name ?
disk_real_name = i['disk_name'] disk_real_name = i['disk_name']
disk_name = self.has_alias(i['disk_name']) disk_name = self.has_alias(i['disk_name'])