mirror of
https://github.com/nicolargo/glances.git
synced 2026-03-15 04:16:22 -04:00
Workarround for the issue931. Not solve the issue but implement correctly the --disable-<plugin> option for all plugins
This commit is contained in:
@@ -48,6 +48,7 @@ class Plugin(GlancesPlugin):
|
||||
"""Reset/init the stats."""
|
||||
self.stats = []
|
||||
|
||||
@GlancesPlugin._check_decorator
|
||||
@GlancesPlugin._log_result_decorator
|
||||
def update(self):
|
||||
"""Update the AMP list."""
|
||||
|
||||
@@ -54,6 +54,7 @@ class Plugin(GlancesPlugin):
|
||||
"""Reset/init the stats."""
|
||||
self.stats = []
|
||||
|
||||
@GlancesPlugin._check_decorator
|
||||
@GlancesPlugin._log_result_decorator
|
||||
def update(self):
|
||||
"""Update battery capacity stats using the input method."""
|
||||
|
||||
@@ -84,6 +84,7 @@ class Plugin(GlancesPlugin):
|
||||
"""Reset/init the stats."""
|
||||
self.stats = {}
|
||||
|
||||
@GlancesPlugin._check_decorator
|
||||
@GlancesPlugin._log_result_decorator
|
||||
def update(self):
|
||||
"""Update CPU stats using the input method."""
|
||||
|
||||
@@ -65,6 +65,7 @@ class Plugin(GlancesPlugin):
|
||||
"""Reset/init the stats."""
|
||||
self.stats = []
|
||||
|
||||
@GlancesPlugin._check_decorator
|
||||
@GlancesPlugin._log_result_decorator
|
||||
def update(self):
|
||||
"""Update disk I/O stats using the input method."""
|
||||
|
||||
@@ -66,6 +66,9 @@ class Plugin(GlancesPlugin):
|
||||
# value: instance of ThreadDockerGrabber
|
||||
self.thread_list = {}
|
||||
|
||||
# Init the stats
|
||||
self.reset()
|
||||
|
||||
def exit(self):
|
||||
"""Overwrite the exit method to close threads"""
|
||||
for t in itervalues(self.thread_list):
|
||||
@@ -141,6 +144,7 @@ class Plugin(GlancesPlugin):
|
||||
"""Reset/init the stats."""
|
||||
self.stats = {}
|
||||
|
||||
@GlancesPlugin._check_decorator
|
||||
@GlancesPlugin._log_result_decorator
|
||||
def update(self):
|
||||
"""Update Docker stats using the input method."""
|
||||
|
||||
@@ -52,6 +52,8 @@ class Plugin(GlancesPlugin):
|
||||
"""Load the foldered list from the config file, if it exists."""
|
||||
self.glances_folders = glancesFolderList(config)
|
||||
|
||||
@GlancesPlugin._check_decorator
|
||||
@GlancesPlugin._log_result_decorator
|
||||
def update(self):
|
||||
"""Update the foldered list."""
|
||||
# Reset the list
|
||||
|
||||
@@ -89,6 +89,7 @@ class Plugin(GlancesPlugin):
|
||||
"""Reset/init the stats."""
|
||||
self.stats = []
|
||||
|
||||
@GlancesPlugin._check_decorator
|
||||
@GlancesPlugin._log_result_decorator
|
||||
def update(self):
|
||||
"""Update the FS stats using the input method."""
|
||||
|
||||
@@ -52,6 +52,8 @@ class Plugin(GlancesPlugin):
|
||||
"""Reset/init the stats."""
|
||||
self.stats = []
|
||||
|
||||
@GlancesPlugin._check_decorator
|
||||
@GlancesPlugin._log_result_decorator
|
||||
def update(self):
|
||||
"""Update HDD stats using the input method."""
|
||||
# Reset stats
|
||||
|
||||
@@ -75,6 +75,7 @@ class Plugin(GlancesPlugin):
|
||||
"""Reset/init the stats."""
|
||||
self.stats = {}
|
||||
|
||||
@GlancesPlugin._check_decorator
|
||||
@GlancesPlugin._log_result_decorator
|
||||
def update(self):
|
||||
"""Update IP stats using the input method.
|
||||
|
||||
@@ -52,6 +52,7 @@ class Plugin(GlancesPlugin):
|
||||
"""Reset/init the stats."""
|
||||
self.stats = []
|
||||
|
||||
@GlancesPlugin._check_decorator
|
||||
@GlancesPlugin._log_result_decorator
|
||||
def update(self):
|
||||
"""Update the IRQ stats"""
|
||||
|
||||
@@ -74,6 +74,7 @@ class Plugin(GlancesPlugin):
|
||||
"""Reset/init the stats."""
|
||||
self.stats = {}
|
||||
|
||||
@GlancesPlugin._check_decorator
|
||||
@GlancesPlugin._log_result_decorator
|
||||
def update(self):
|
||||
"""Update load stats."""
|
||||
|
||||
@@ -76,6 +76,7 @@ class Plugin(GlancesPlugin):
|
||||
"""Reset/init the stats."""
|
||||
self.stats = {}
|
||||
|
||||
@GlancesPlugin._check_decorator
|
||||
@GlancesPlugin._log_result_decorator
|
||||
def update(self):
|
||||
"""Update RAM memory stats using the input method."""
|
||||
|
||||
@@ -64,6 +64,7 @@ class Plugin(GlancesPlugin):
|
||||
"""Reset/init the stats."""
|
||||
self.stats = {}
|
||||
|
||||
@GlancesPlugin._check_decorator
|
||||
@GlancesPlugin._log_result_decorator
|
||||
def update(self):
|
||||
"""Update swap memory stats using the input method."""
|
||||
|
||||
@@ -72,6 +72,7 @@ class Plugin(GlancesPlugin):
|
||||
"""Reset/init the stats."""
|
||||
self.stats = []
|
||||
|
||||
@GlancesPlugin._check_decorator
|
||||
@GlancesPlugin._log_result_decorator
|
||||
def update(self):
|
||||
"""Update network stats using the input method.
|
||||
|
||||
@@ -49,6 +49,8 @@ class Plugin(GlancesPlugin):
|
||||
"""Reset/init the stats."""
|
||||
self.stats = []
|
||||
|
||||
@GlancesPlugin._check_decorator
|
||||
@GlancesPlugin._log_result_decorator
|
||||
def update(self):
|
||||
"""Update per-CPU stats using the input method."""
|
||||
# Reset stats
|
||||
|
||||
@@ -86,6 +86,15 @@ class GlancesPlugin(object):
|
||||
"""Return the key of the list."""
|
||||
return None
|
||||
|
||||
def is_enable(self):
|
||||
"""Return true if plugin is enable"""
|
||||
try:
|
||||
d = getattr(self.args, 'disable_' + self.plugin_name)
|
||||
except AttributeError:
|
||||
return True
|
||||
else:
|
||||
return d is False
|
||||
|
||||
def _json_dumps(self, d):
|
||||
"""Return the object 'd' in a JSON format
|
||||
Manage the issue #815 for Windows OS"""
|
||||
@@ -746,6 +755,16 @@ class GlancesPlugin(object):
|
||||
value, decimal=decimal_precision, symbol=symbol)
|
||||
return '{!s}'.format(number)
|
||||
|
||||
def _check_decorator(fct):
|
||||
"""Check if the plugin is enabled."""
|
||||
def wrapper(self, *args, **kw):
|
||||
if self.is_enable():
|
||||
ret = fct(self, *args, **kw)
|
||||
else:
|
||||
ret = self.stats
|
||||
return ret
|
||||
return wrapper
|
||||
|
||||
def _log_result_decorator(fct):
|
||||
"""Log (DEBUG) the result of the function fct."""
|
||||
def wrapper(*args, **kw):
|
||||
@@ -758,4 +777,5 @@ class GlancesPlugin(object):
|
||||
return wrapper
|
||||
|
||||
# Mandatory to call the decorator in childs' classes
|
||||
_check_decorator = staticmethod(_check_decorator)
|
||||
_log_result_decorator = staticmethod(_log_result_decorator)
|
||||
|
||||
@@ -37,6 +37,8 @@ class Plugin(GlancesPlugin):
|
||||
"""Reset/init the stats."""
|
||||
self.stats = None
|
||||
|
||||
@GlancesPlugin._check_decorator
|
||||
@GlancesPlugin._log_result_decorator
|
||||
def update(self):
|
||||
"""Update the stats."""
|
||||
# Reset stats
|
||||
|
||||
@@ -58,6 +58,7 @@ class Plugin(GlancesPlugin):
|
||||
"""Reset/init the stats."""
|
||||
self.stats = {}
|
||||
|
||||
@GlancesPlugin._check_decorator
|
||||
@GlancesPlugin._log_result_decorator
|
||||
def update(self):
|
||||
"""Update quicklook stats using the input method."""
|
||||
|
||||
@@ -51,6 +51,7 @@ class Plugin(GlancesPlugin):
|
||||
"""Reset/init the stats."""
|
||||
self.stats = {}
|
||||
|
||||
@GlancesPlugin._check_decorator
|
||||
@GlancesPlugin._log_result_decorator
|
||||
def update(self):
|
||||
"""Update RAID stats using the input method."""
|
||||
|
||||
@@ -78,6 +78,7 @@ class Plugin(GlancesPlugin):
|
||||
"""Reset/init the stats."""
|
||||
self.stats = []
|
||||
|
||||
@GlancesPlugin._check_decorator
|
||||
@GlancesPlugin._log_result_decorator
|
||||
def update(self):
|
||||
"""Update sensors stats using the input method."""
|
||||
|
||||
@@ -96,6 +96,8 @@ class Plugin(GlancesPlugin):
|
||||
"""Reset/init the stats."""
|
||||
self.stats = {}
|
||||
|
||||
@GlancesPlugin._check_decorator
|
||||
@GlancesPlugin._log_result_decorator
|
||||
def update(self):
|
||||
"""Update the host/system info using the input method.
|
||||
|
||||
|
||||
@@ -53,6 +53,8 @@ class Plugin(GlancesPlugin):
|
||||
"""Reset/init the stats."""
|
||||
self.stats = {}
|
||||
|
||||
@GlancesPlugin._check_decorator
|
||||
@GlancesPlugin._log_result_decorator
|
||||
def update(self):
|
||||
"""Update uptime stat using the input method."""
|
||||
# Reset stats
|
||||
|
||||
Reference in New Issue
Block a user