Avoid none in rate computation

This commit is contained in:
nicolargo 2025-06-28 20:14:12 +02:00
parent 28ae053e4b
commit 1434d3ad5c
3 changed files with 11 additions and 5 deletions

View File

@ -59,6 +59,7 @@ class GlancesStdout:
stat = stats.get_plugin(plugin).get_export()
else:
continue
# Display stats
if attribute is not None:
# With attribute

View File

@ -114,10 +114,15 @@ class NetworkPlugin(GlancesPluginModel):
"""
if self.input_method == 'local':
stats = self.update_local()
# Update the stats
for stat in stats:
if stat.get('bytes_recv') is None:
print(f"def update: bytes_recv is None for {stat['interface_name']}")
else:
stats = self.get_init_value()
# Update the stats
self.stats = stats
return self.stats

View File

@ -1187,12 +1187,12 @@ class GlancesPluginModel:
if self.time_since_last_update > 0:
stat[field + '_rate_per_sec'] = stat[field] // self.time_since_last_update
else:
stat[field] = None
stat[field + '_rate_per_sec'] = None
stat[field] = 0
stat[field + '_rate_per_sec'] = 0
else:
# Avoid strange rate at the first run
stat[field] = None
stat[field + '_rate_per_sec'] = None
stat[field] = 0
stat[field + '_rate_per_sec'] = 0
return stat
def compute_rate_on_list(self, stats, stats_previous):