mirror of
https://pagure.io/fedora-infra/ansible.git
synced 2026-03-20 03:57:02 +08:00
updates+uptimes: Use verscmp() for osinfo in stats.
Signed-off-by: James Antill <james@and.org>
This commit is contained in:
@@ -224,6 +224,31 @@ def verscmp(x, y):
|
||||
return len(xc) - len(yc)
|
||||
|
||||
|
||||
class VerscmpString():
|
||||
__slots__ = ['s',]
|
||||
def __init__(self, s):
|
||||
self.s = s
|
||||
|
||||
def __str__(self):
|
||||
return self.s
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.s == other.s
|
||||
|
||||
def __gt__(self, other):
|
||||
ret = verscmp(self.s, other.s)
|
||||
if ret > 0:
|
||||
return True
|
||||
if False and ret < 0:
|
||||
return False
|
||||
return False
|
||||
|
||||
# Given a list of strings, sort them using verscmp()
|
||||
def _verscmp_strings(xs):
|
||||
for ret in sorted(VerscmpString(x) for x in xs):
|
||||
yield ret.s
|
||||
|
||||
|
||||
# Have nice "plain" numbers...
|
||||
def _ui_int(num):
|
||||
if conf_num_sep_:
|
||||
@@ -1253,7 +1278,7 @@ def _cmd_stats(args):
|
||||
max_nhosts_lvl_2 = 0
|
||||
max_update_lvl_2 = 0
|
||||
max_uptime_lvl_2 = 0
|
||||
for osi in sorted(osdata['hosts']):
|
||||
for osi in _verscmp_strings(osdata['hosts']):
|
||||
if '/' not in osi:
|
||||
max_nhosts_lvl_1 = max(max_nhosts_lvl_1, osdata['hosts'][osi])
|
||||
supd = osdata['updates'][osi] / osdata['hosts'][osi]
|
||||
@@ -1301,7 +1326,7 @@ def _cmd_stats(args):
|
||||
suf = _ui_t_high(suf)
|
||||
return uiosi, uinhosts, uiupdates, uiuptimes, uinpdates, uinptimes, suf
|
||||
|
||||
for osi in sorted(osdata['hosts']):
|
||||
for osi in _verscmp_strings(osdata['hosts']):
|
||||
if '/' not in osi:
|
||||
if len(osdata['vers'][osi]) == 1:
|
||||
subprefix = ''
|
||||
|
||||
Reference in New Issue
Block a user