mirror of
https://github.com/nicolargo/glances.git
synced 2024-09-11 12:47:14 +03:00
Improve code
This commit is contained in:
parent
4ddff48c70
commit
ada7f248ba
@ -188,16 +188,14 @@ class GlancesPluginModel(object):
|
||||
def update_stats_history(self):
|
||||
"""Update stats history."""
|
||||
# Build the history
|
||||
if self.get_export() and self.history_enable():
|
||||
# If the plugin data is a dict, the dict's key should be used
|
||||
if self.get_key() is None:
|
||||
item_name = ''
|
||||
else:
|
||||
item_name = self.get_key()
|
||||
if not (self.get_export() and self.history_enable()):
|
||||
return
|
||||
# Itern through items history
|
||||
item_name = '' if self.get_key() is None else self.get_key()
|
||||
for i in self.get_items_history_list():
|
||||
if isinstance(self.get_export(), list):
|
||||
# Stats is a list of data
|
||||
# Iter through it (for example, iter through network interface)
|
||||
# Iter through stats (for example, iter through network interface)
|
||||
for l_export in self.get_export():
|
||||
if i['name'] in l_export:
|
||||
self.stats_history.add(
|
||||
|
@ -90,18 +90,16 @@ class TestGlances(unittest.TestCase):
|
||||
# Check stats
|
||||
self.assertIsInstance(plugin_instance.get_raw(), (dict, list))
|
||||
if isinstance(plugin_instance.get_raw(), dict):
|
||||
# self.assertTrue(any([f in plugin_instance.get_raw() for f in plugin_instance.fields_description]))
|
||||
res = False
|
||||
for f in plugin_instance.fields_description:
|
||||
if f not in plugin_instance.get_raw():
|
||||
print(f"WARNING: {f} not found in {plugin} plugin fields_description")
|
||||
print(f"WARNING: {f} field not found in {plugin} plugin stats")
|
||||
else:
|
||||
res = True
|
||||
self.assertTrue(res)
|
||||
elif isinstance(plugin_instance.get_raw(), list):
|
||||
res = False
|
||||
for i in plugin_instance.get_raw():
|
||||
# self.assertTrue(all([f in plugin_instance.fields_description for f in i]))
|
||||
for f in i:
|
||||
if f in plugin_instance.fields_description:
|
||||
res = True
|
||||
|
Loading…
Reference in New Issue
Block a user