mirror of
https://github.com/nicolargo/glances.git
synced 2024-12-23 01:01:31 +03:00
Move alias aware sorting to glances_plugin
This commit is contained in:
parent
56229d238a
commit
7a47c32341
@ -180,10 +180,7 @@ 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=lambda stat: tuple(map(
|
for i in self.sorted_stats('disk_name'):
|
||||||
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'])
|
||||||
|
@ -286,6 +286,13 @@ class GlancesPlugin(object):
|
|||||||
"""Get the short detected OS name (SNMP)."""
|
"""Get the short detected OS name (SNMP)."""
|
||||||
return self._short_system_name
|
return self._short_system_name
|
||||||
|
|
||||||
|
def sorted_stats(self, key):
|
||||||
|
"""Get the stats sorted by an alias (if present) or key."""
|
||||||
|
return sorted(self.stats, key=lambda stat: tuple(map(
|
||||||
|
lambda part: int(part) if part.isdigit() else part.lower(),
|
||||||
|
re.split(r"(\d+|\D+)", self.has_alias(stat[key]) or stat[key])
|
||||||
|
)))
|
||||||
|
|
||||||
@short_system_name.setter
|
@short_system_name.setter
|
||||||
def short_system_name(self, short_name):
|
def short_system_name(self, short_name):
|
||||||
"""Set the short detected OS name (SNMP)."""
|
"""Set the short detected OS name (SNMP)."""
|
||||||
|
Loading…
Reference in New Issue
Block a user