From 1e36444f18f10cd558e39890903e5de821a12925 Mon Sep 17 00:00:00 2001 From: nicolargo Date: Sat, 17 Dec 2016 10:35:09 +0100 Subject: [PATCH] Correct an issue in PR issue #979 (for #issue #170) because the get_stats method overwrite the default get_method. Rename it to get_device_stats --- glances/plugins/glances_gpu.py | 8 +++++--- unitest-restful.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/glances/plugins/glances_gpu.py b/glances/plugins/glances_gpu.py index 765b44e4..e758b81b 100644 --- a/glances/plugins/glances_gpu.py +++ b/glances/plugins/glances_gpu.py @@ -71,6 +71,7 @@ class Plugin(GlancesPlugin): return self.nvml_ready + @GlancesPlugin._check_decorator @GlancesPlugin._log_result_decorator def update(self): """Update the GPU stats""" @@ -81,13 +82,13 @@ class Plugin(GlancesPlugin): return self.stats if self.input_method == 'local': - self.stats = self.get_stats() + self.stats = self.get_device_stats() elif self.input_method == 'snmp': # not available pass # Update the view - self.update_views() + # self.update_views() return self.stats @@ -101,9 +102,10 @@ class Plugin(GlancesPlugin): """ return [pynvml.nvmlDeviceGetHandleByIndex(i) for i in range(0, pynvml.nvmlDeviceGetCount())] - def get_stats(self): + def get_device_stats(self): """Get GPU stats""" stats = [] + for index, device_handle in enumerate(self.device_handles): device_stats = {} device_stats['key'] = index diff --git a/unitest-restful.py b/unitest-restful.py index 8c11ed93..aea91e24 100755 --- a/unitest-restful.py +++ b/unitest-restful.py @@ -95,7 +95,7 @@ class TestGlances(unittest.TestCase): self.assertIsInstance(req.json(), text_type) elif p in ('fs', 'percpu', 'sensors', 'alert', 'processlist', 'diskio', 'hddtemp', 'batpercent', 'network', 'folders', 'amps', 'ports', - 'irq', 'wifi'): + 'irq', 'wifi', 'gpu'): self.assertIsInstance(req.json(), list) elif p in ('psutilversion', 'help'): pass