提交 b1d41bcf 编写于 作者: N nicolargo

Workarround for the issue931. Not solve the issue but implement correctly the...

Workarround for the issue931. Not solve the issue but implement correctly the --disable-<plugin> option for all plugins
上级 2acdbe9c
...@@ -48,6 +48,7 @@ class Plugin(GlancesPlugin): ...@@ -48,6 +48,7 @@ class Plugin(GlancesPlugin):
"""Reset/init the stats.""" """Reset/init the stats."""
self.stats = [] self.stats = []
@GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator @GlancesPlugin._log_result_decorator
def update(self): def update(self):
"""Update the AMP list.""" """Update the AMP list."""
......
...@@ -54,6 +54,7 @@ class Plugin(GlancesPlugin): ...@@ -54,6 +54,7 @@ class Plugin(GlancesPlugin):
"""Reset/init the stats.""" """Reset/init the stats."""
self.stats = [] self.stats = []
@GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator @GlancesPlugin._log_result_decorator
def update(self): def update(self):
"""Update battery capacity stats using the input method.""" """Update battery capacity stats using the input method."""
......
...@@ -84,6 +84,7 @@ class Plugin(GlancesPlugin): ...@@ -84,6 +84,7 @@ class Plugin(GlancesPlugin):
"""Reset/init the stats.""" """Reset/init the stats."""
self.stats = {} self.stats = {}
@GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator @GlancesPlugin._log_result_decorator
def update(self): def update(self):
"""Update CPU stats using the input method.""" """Update CPU stats using the input method."""
......
...@@ -65,6 +65,7 @@ class Plugin(GlancesPlugin): ...@@ -65,6 +65,7 @@ class Plugin(GlancesPlugin):
"""Reset/init the stats.""" """Reset/init the stats."""
self.stats = [] self.stats = []
@GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator @GlancesPlugin._log_result_decorator
def update(self): def update(self):
"""Update disk I/O stats using the input method.""" """Update disk I/O stats using the input method."""
......
...@@ -66,6 +66,9 @@ class Plugin(GlancesPlugin): ...@@ -66,6 +66,9 @@ class Plugin(GlancesPlugin):
# value: instance of ThreadDockerGrabber # value: instance of ThreadDockerGrabber
self.thread_list = {} self.thread_list = {}
# Init the stats
self.reset()
def exit(self): def exit(self):
"""Overwrite the exit method to close threads""" """Overwrite the exit method to close threads"""
for t in itervalues(self.thread_list): for t in itervalues(self.thread_list):
...@@ -141,6 +144,7 @@ class Plugin(GlancesPlugin): ...@@ -141,6 +144,7 @@ class Plugin(GlancesPlugin):
"""Reset/init the stats.""" """Reset/init the stats."""
self.stats = {} self.stats = {}
@GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator @GlancesPlugin._log_result_decorator
def update(self): def update(self):
"""Update Docker stats using the input method.""" """Update Docker stats using the input method."""
......
...@@ -52,6 +52,8 @@ class Plugin(GlancesPlugin): ...@@ -52,6 +52,8 @@ class Plugin(GlancesPlugin):
"""Load the foldered list from the config file, if it exists.""" """Load the foldered list from the config file, if it exists."""
self.glances_folders = glancesFolderList(config) self.glances_folders = glancesFolderList(config)
@GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator
def update(self): def update(self):
"""Update the foldered list.""" """Update the foldered list."""
# Reset the list # Reset the list
......
...@@ -89,6 +89,7 @@ class Plugin(GlancesPlugin): ...@@ -89,6 +89,7 @@ class Plugin(GlancesPlugin):
"""Reset/init the stats.""" """Reset/init the stats."""
self.stats = [] self.stats = []
@GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator @GlancesPlugin._log_result_decorator
def update(self): def update(self):
"""Update the FS stats using the input method.""" """Update the FS stats using the input method."""
......
...@@ -52,6 +52,8 @@ class Plugin(GlancesPlugin): ...@@ -52,6 +52,8 @@ class Plugin(GlancesPlugin):
"""Reset/init the stats.""" """Reset/init the stats."""
self.stats = [] self.stats = []
@GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator
def update(self): def update(self):
"""Update HDD stats using the input method.""" """Update HDD stats using the input method."""
# Reset stats # Reset stats
......
...@@ -75,6 +75,7 @@ class Plugin(GlancesPlugin): ...@@ -75,6 +75,7 @@ class Plugin(GlancesPlugin):
"""Reset/init the stats.""" """Reset/init the stats."""
self.stats = {} self.stats = {}
@GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator @GlancesPlugin._log_result_decorator
def update(self): def update(self):
"""Update IP stats using the input method. """Update IP stats using the input method.
......
...@@ -52,6 +52,7 @@ class Plugin(GlancesPlugin): ...@@ -52,6 +52,7 @@ class Plugin(GlancesPlugin):
"""Reset/init the stats.""" """Reset/init the stats."""
self.stats = [] self.stats = []
@GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator @GlancesPlugin._log_result_decorator
def update(self): def update(self):
"""Update the IRQ stats""" """Update the IRQ stats"""
......
...@@ -74,6 +74,7 @@ class Plugin(GlancesPlugin): ...@@ -74,6 +74,7 @@ class Plugin(GlancesPlugin):
"""Reset/init the stats.""" """Reset/init the stats."""
self.stats = {} self.stats = {}
@GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator @GlancesPlugin._log_result_decorator
def update(self): def update(self):
"""Update load stats.""" """Update load stats."""
......
...@@ -76,6 +76,7 @@ class Plugin(GlancesPlugin): ...@@ -76,6 +76,7 @@ class Plugin(GlancesPlugin):
"""Reset/init the stats.""" """Reset/init the stats."""
self.stats = {} self.stats = {}
@GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator @GlancesPlugin._log_result_decorator
def update(self): def update(self):
"""Update RAM memory stats using the input method.""" """Update RAM memory stats using the input method."""
......
...@@ -64,6 +64,7 @@ class Plugin(GlancesPlugin): ...@@ -64,6 +64,7 @@ class Plugin(GlancesPlugin):
"""Reset/init the stats.""" """Reset/init the stats."""
self.stats = {} self.stats = {}
@GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator @GlancesPlugin._log_result_decorator
def update(self): def update(self):
"""Update swap memory stats using the input method.""" """Update swap memory stats using the input method."""
......
...@@ -72,6 +72,7 @@ class Plugin(GlancesPlugin): ...@@ -72,6 +72,7 @@ class Plugin(GlancesPlugin):
"""Reset/init the stats.""" """Reset/init the stats."""
self.stats = [] self.stats = []
@GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator @GlancesPlugin._log_result_decorator
def update(self): def update(self):
"""Update network stats using the input method. """Update network stats using the input method.
......
...@@ -49,6 +49,8 @@ class Plugin(GlancesPlugin): ...@@ -49,6 +49,8 @@ class Plugin(GlancesPlugin):
"""Reset/init the stats.""" """Reset/init the stats."""
self.stats = [] self.stats = []
@GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator
def update(self): def update(self):
"""Update per-CPU stats using the input method.""" """Update per-CPU stats using the input method."""
# Reset stats # Reset stats
......
...@@ -86,6 +86,15 @@ class GlancesPlugin(object): ...@@ -86,6 +86,15 @@ class GlancesPlugin(object):
"""Return the key of the list.""" """Return the key of the list."""
return None 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): def _json_dumps(self, d):
"""Return the object 'd' in a JSON format """Return the object 'd' in a JSON format
Manage the issue #815 for Windows OS""" Manage the issue #815 for Windows OS"""
...@@ -746,6 +755,16 @@ class GlancesPlugin(object): ...@@ -746,6 +755,16 @@ class GlancesPlugin(object):
value, decimal=decimal_precision, symbol=symbol) value, decimal=decimal_precision, symbol=symbol)
return '{!s}'.format(number) 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): def _log_result_decorator(fct):
"""Log (DEBUG) the result of the function fct.""" """Log (DEBUG) the result of the function fct."""
def wrapper(*args, **kw): def wrapper(*args, **kw):
...@@ -758,4 +777,5 @@ class GlancesPlugin(object): ...@@ -758,4 +777,5 @@ class GlancesPlugin(object):
return wrapper return wrapper
# Mandatory to call the decorator in childs' classes # Mandatory to call the decorator in childs' classes
_check_decorator = staticmethod(_check_decorator)
_log_result_decorator = staticmethod(_log_result_decorator) _log_result_decorator = staticmethod(_log_result_decorator)
...@@ -37,6 +37,8 @@ class Plugin(GlancesPlugin): ...@@ -37,6 +37,8 @@ class Plugin(GlancesPlugin):
"""Reset/init the stats.""" """Reset/init the stats."""
self.stats = None self.stats = None
@GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator
def update(self): def update(self):
"""Update the stats.""" """Update the stats."""
# Reset stats # Reset stats
......
...@@ -58,6 +58,7 @@ class Plugin(GlancesPlugin): ...@@ -58,6 +58,7 @@ class Plugin(GlancesPlugin):
"""Reset/init the stats.""" """Reset/init the stats."""
self.stats = {} self.stats = {}
@GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator @GlancesPlugin._log_result_decorator
def update(self): def update(self):
"""Update quicklook stats using the input method.""" """Update quicklook stats using the input method."""
......
...@@ -51,6 +51,7 @@ class Plugin(GlancesPlugin): ...@@ -51,6 +51,7 @@ class Plugin(GlancesPlugin):
"""Reset/init the stats.""" """Reset/init the stats."""
self.stats = {} self.stats = {}
@GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator @GlancesPlugin._log_result_decorator
def update(self): def update(self):
"""Update RAID stats using the input method.""" """Update RAID stats using the input method."""
......
...@@ -78,6 +78,7 @@ class Plugin(GlancesPlugin): ...@@ -78,6 +78,7 @@ class Plugin(GlancesPlugin):
"""Reset/init the stats.""" """Reset/init the stats."""
self.stats = [] self.stats = []
@GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator @GlancesPlugin._log_result_decorator
def update(self): def update(self):
"""Update sensors stats using the input method.""" """Update sensors stats using the input method."""
......
...@@ -96,6 +96,8 @@ class Plugin(GlancesPlugin): ...@@ -96,6 +96,8 @@ class Plugin(GlancesPlugin):
"""Reset/init the stats.""" """Reset/init the stats."""
self.stats = {} self.stats = {}
@GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator
def update(self): def update(self):
"""Update the host/system info using the input method. """Update the host/system info using the input method.
......
...@@ -53,6 +53,8 @@ class Plugin(GlancesPlugin): ...@@ -53,6 +53,8 @@ class Plugin(GlancesPlugin):
"""Reset/init the stats.""" """Reset/init the stats."""
self.stats = {} self.stats = {}
@GlancesPlugin._check_decorator
@GlancesPlugin._log_result_decorator
def update(self): def update(self):
"""Update uptime stat using the input method.""" """Update uptime stat using the input method."""
# Reset stats # Reset stats
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册