When converting a value in bytes to human-readable, if the conversion fails then log a warning and return the original value instead of raising an exception.
This commit is contained in:
parent
c2d5cbadd6
commit
1d8913f408
|
@ -292,9 +292,11 @@ class ConversionUtil(object):
|
||||||
for i, (factor, suffix) in enumerate(system):
|
for i, (factor, suffix) in enumerate(system):
|
||||||
if suffix == min_suffix:
|
if suffix == min_suffix:
|
||||||
if value < factor:
|
if value < factor:
|
||||||
assert i + 1 < len(system), \
|
if i + 1 >= len(system):
|
||||||
('i + 1 >= len(system) (i + 1: {}, len(system): {}, value: {}, '
|
LOG.warning("Error converting value '%s': min_suffix='%s' at index='%s' "
|
||||||
'min_suffix: {})').format(i + 1, len(system), value, min_suffix)
|
"is already the smallest suffix.", value, min_suffix, i)
|
||||||
|
return value
|
||||||
|
|
||||||
min_suffix = system[i + 1][1]
|
min_suffix = system[i + 1][1]
|
||||||
LOG.warning('The value is smaller than the min factor: %s < %s%s. '
|
LOG.warning('The value is smaller than the min factor: %s < %s%s. '
|
||||||
'Setting min_suffix=%s...', value, factor, suffix, min_suffix)
|
'Setting min_suffix=%s...', value, factor, suffix, min_suffix)
|
||||||
|
|
Loading…
Reference in New Issue