mirror of https://github.com/nicolargo/glances.git
Resolve conflict with PR #1949
This commit is contained in:
commit
3d93926294
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 210 KiB After Width: | Height: | Size: 210 KiB |
|
|
@ -132,9 +132,10 @@ def main():
|
|||
|
||||
# Log Glances and psutil version
|
||||
logger.info('Start Glances {}'.format(__version__))
|
||||
logger.info('{} {} and psutil {} detected'.format(
|
||||
logger.info('{} {} ({}) and psutil {} detected'.format(
|
||||
platform.python_implementation(),
|
||||
platform.python_version(),
|
||||
sys.executable,
|
||||
psutil_version))
|
||||
|
||||
# Share global var
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class GlancesStdout(object):
|
|||
for plugin, attribute in self.plugins_list:
|
||||
# Check if the plugin exist and is enable
|
||||
if plugin in stats.getPluginsList() and \
|
||||
stats.get_plugin(plugin).is_enable():
|
||||
stats.get_plugin(plugin).is_enabled():
|
||||
stat = stats.get_plugin(plugin).get_export()
|
||||
else:
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ class GlancesStdoutCsv(object):
|
|||
for plugin, attribute in self.plugins_list:
|
||||
# Check if the plugin exist and is enable
|
||||
if plugin in stats.getPluginsList() and \
|
||||
stats.get_plugin(plugin).is_enable():
|
||||
stats.get_plugin(plugin).is_enabled():
|
||||
stat = stats.get_plugin(plugin).get_export()
|
||||
else:
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -19,15 +19,18 @@
|
|||
|
||||
"""Issue interface class."""
|
||||
|
||||
import time
|
||||
import os
|
||||
import sys
|
||||
import platform
|
||||
import shutil
|
||||
import time
|
||||
|
||||
from glances.logger import logger
|
||||
from glances.globals import printandflush
|
||||
from glances.timer import Counter
|
||||
from glances import __version__, psutil_version
|
||||
|
||||
import psutil
|
||||
import glances
|
||||
|
||||
try:
|
||||
TERMINAL_WIDTH = shutil.get_terminal_size(fallback=(79, 24)).columns
|
||||
except:
|
||||
|
|
@ -64,13 +67,17 @@ class GlancesStdoutIssue(object):
|
|||
pass
|
||||
|
||||
def print_version(self):
|
||||
msg = 'Glances version {} with PsUtil {}'.format(
|
||||
sys.stdout.write('=' * TERMINAL_WIDTH + '\n')
|
||||
sys.stdout.write('Glances {} ({})\n'.format(
|
||||
colors.BLUE + __version__ + colors.NO,
|
||||
colors.BLUE + psutil_version + colors.NO)
|
||||
sys.stdout.write('='*len(msg) + '\n')
|
||||
sys.stdout.write(msg)
|
||||
sys.stdout.write(colors.NO + '\n')
|
||||
sys.stdout.write('='*len(msg) + '\n')
|
||||
os.path.realpath(glances.__file__)))
|
||||
sys.stdout.write('Python {} ({})\n'.format(
|
||||
colors.BLUE + platform.python_version() + colors.NO,
|
||||
sys.executable))
|
||||
sys.stdout.write('PsUtil {} ({})\n'.format(
|
||||
colors.BLUE + psutil_version + colors.NO,
|
||||
os.path.realpath(psutil.__file__)))
|
||||
sys.stdout.write('=' * TERMINAL_WIDTH + '\n')
|
||||
sys.stdout.flush()
|
||||
|
||||
def print_issue(self, plugin, result, message):
|
||||
|
|
@ -85,8 +92,20 @@ class GlancesStdoutIssue(object):
|
|||
"""Display issue
|
||||
"""
|
||||
self.print_version()
|
||||
|
||||
for plugin in sorted(stats._plugins):
|
||||
if stats._plugins[plugin].is_disable():
|
||||
if stats._plugins[plugin].is_disabled():
|
||||
continue
|
||||
try:
|
||||
# Update the stats
|
||||
stats._plugins[plugin].update()
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
for plugin in sorted(stats._plugins):
|
||||
if stats._plugins[plugin].is_disabled():
|
||||
# If current plugin is disable
|
||||
# then continue to next plugin
|
||||
result = colors.NO + '[N/A]'.rjust(19 - len(plugin))
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ class PluginModel(GlancesPluginModel):
|
|||
ret = []
|
||||
|
||||
# Only process if display plugin enable...
|
||||
if not self.stats or self.is_disable():
|
||||
if not self.stats or self.is_disabled():
|
||||
return ret
|
||||
|
||||
# Build the string message
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ class PluginModel(GlancesPluginModel):
|
|||
# Only process if stats exist and display plugin enable...
|
||||
ret = []
|
||||
|
||||
if not self.stats or args.disable_process or self.is_disable():
|
||||
if not self.stats or args.disable_process or self.is_disabled():
|
||||
return ret
|
||||
|
||||
# Build the string message
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ class PluginModel(GlancesPluginModel):
|
|||
# Init the return message
|
||||
ret = []
|
||||
|
||||
if not self.stats or self.stats == {} or self.is_disable():
|
||||
if not self.stats or self.stats == {} or self.is_disabled():
|
||||
return ret
|
||||
|
||||
# Generate the output
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ class PluginModel(GlancesPluginModel):
|
|||
ret = []
|
||||
|
||||
# Only process if stats exist and display plugin enable...
|
||||
if not self.stats or self.is_disable():
|
||||
if not self.stats or self.is_disabled():
|
||||
return ret
|
||||
|
||||
# Header
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ class PluginModel(GlancesPluginModel):
|
|||
ret = []
|
||||
|
||||
# Only process if stats exist and plugin not disable
|
||||
if not self.stats or self.args.percpu or self.is_disable():
|
||||
if not self.stats or self.args.percpu or self.is_disabled():
|
||||
return ret
|
||||
|
||||
# Build the string message
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ class PluginModel(GlancesPluginModel):
|
|||
ret = []
|
||||
|
||||
# Only process if stats exist and display plugin enable...
|
||||
if not self.stats or self.is_disable():
|
||||
if not self.stats or self.is_disabled():
|
||||
return ret
|
||||
|
||||
# Max size for the interface name
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ class PluginModel(GlancesPluginModel):
|
|||
ret = []
|
||||
|
||||
# Only process if stats exist and display plugin enable...
|
||||
if not self.stats or self.is_disable():
|
||||
if not self.stats or self.is_disabled():
|
||||
return ret
|
||||
|
||||
# Max size for the interface name
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ class PluginModel(GlancesPluginModel):
|
|||
ret = []
|
||||
|
||||
# Only process if stats exist and display plugin enable...
|
||||
if not self.stats or self.is_disable():
|
||||
if not self.stats or self.is_disabled():
|
||||
return ret
|
||||
|
||||
# Max size for the interface name
|
||||
|
|
|
|||
|
|
@ -570,7 +570,7 @@ class PluginModel(GlancesPluginModel):
|
|||
# Only process if stats exist (and non null) and display plugin enable...
|
||||
if not self.stats \
|
||||
or 'containers' not in self.stats or len(self.stats['containers']) == 0 \
|
||||
or self.is_disable():
|
||||
or self.is_disabled():
|
||||
return ret
|
||||
|
||||
# Build the string message
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ class PluginModel(GlancesPluginModel):
|
|||
ret = []
|
||||
|
||||
# Only process if stats exist, not empty (issue #871) and plugin not disabled
|
||||
if not self.stats or (self.stats == []) or self.is_disable():
|
||||
if not self.stats or (self.stats == []) or self.is_disabled():
|
||||
return ret
|
||||
|
||||
# Check if all GPU have the same name
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ class PluginModel(GlancesPluginModel):
|
|||
ret = []
|
||||
|
||||
# Only process if stats exist and display plugin enable...
|
||||
if not self.stats or self.is_disable() or import_error_tag:
|
||||
if not self.stats or self.is_disabled() or import_error_tag:
|
||||
return ret
|
||||
|
||||
# Build the string message
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ class PluginModel(GlancesPluginModel):
|
|||
|
||||
# Only available on GNU/Linux
|
||||
# Only process if stats exist and display plugin enable...
|
||||
if not LINUX or not self.stats or self.is_disable():
|
||||
if not LINUX or not self.stats or self.is_disabled():
|
||||
return ret
|
||||
|
||||
# Max size for the interface name
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ class PluginModel(GlancesPluginModel):
|
|||
ret = []
|
||||
|
||||
# Only process if stats exist, not empty (issue #871) and plugin not disabled
|
||||
if not self.stats or (self.stats == {}) or self.is_disable():
|
||||
if not self.stats or (self.stats == {}) or self.is_disabled():
|
||||
return ret
|
||||
|
||||
# Build the string message
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ class PluginModel(GlancesPluginModel):
|
|||
ret = []
|
||||
|
||||
# Only process if stats exist and plugin not disabled
|
||||
if not self.stats or self.is_disable():
|
||||
if not self.stats or self.is_disabled():
|
||||
return ret
|
||||
|
||||
# First line
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ class PluginModel(GlancesPluginModel):
|
|||
ret = []
|
||||
|
||||
# Only process if stats exist and plugin not disabled
|
||||
if not self.stats or self.is_disable():
|
||||
if not self.stats or self.is_disabled():
|
||||
return ret
|
||||
|
||||
# First line
|
||||
|
|
|
|||
|
|
@ -300,7 +300,7 @@ class PluginModel(GlancesPluginModel):
|
|||
ret = []
|
||||
|
||||
# Only process if stats exist and display plugin enable...
|
||||
if not self.stats or self.is_disable():
|
||||
if not self.stats or self.is_disabled():
|
||||
return ret
|
||||
|
||||
# Max size for the interface name
|
||||
|
|
|
|||
|
|
@ -78,11 +78,11 @@ class PluginModel(GlancesPluginModel):
|
|||
ret = []
|
||||
|
||||
# Only process if stats exist...
|
||||
if not self.stats or not self.args.percpu or self.is_disable():
|
||||
if not self.stats or not self.args.percpu or self.is_disabled():
|
||||
return ret
|
||||
|
||||
# Build the string message
|
||||
if self.is_disable('quicklook'):
|
||||
if self.is_disabled('quicklook'):
|
||||
msg = '{:7}'.format('PER CPU')
|
||||
ret.append(self.curse_add_line(msg, "TITLE"))
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ class PluginModel(GlancesPluginModel):
|
|||
# Per CPU stats displayed per column
|
||||
for cpu in self.stats:
|
||||
ret.append(self.curse_new_line())
|
||||
if self.is_disable('quicklook'):
|
||||
if self.is_disabled('quicklook'):
|
||||
try:
|
||||
msg = '{:6.1f}%'.format(cpu['total'])
|
||||
except TypeError:
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ class GlancesPluginModel(object):
|
|||
"""Return the key of the list."""
|
||||
return None
|
||||
|
||||
def is_enable(self, plugin_name=None):
|
||||
def is_enabled(self, plugin_name=None):
|
||||
"""Return true if plugin is enabled."""
|
||||
if not plugin_name:
|
||||
plugin_name = self.plugin_name
|
||||
|
|
@ -173,9 +173,9 @@ class GlancesPluginModel(object):
|
|||
d = getattr(self.args, 'enable_' + plugin_name, True)
|
||||
return d is False
|
||||
|
||||
def is_disable(self, plugin_name=None):
|
||||
def is_disabled(self, plugin_name=None):
|
||||
"""Return true if plugin is disabled."""
|
||||
return not self.is_enable(plugin_name=plugin_name)
|
||||
return not self.is_enabled(plugin_name=plugin_name)
|
||||
|
||||
def _json_dumps(self, d):
|
||||
"""Return the object 'd' in a JSON format.
|
||||
|
|
@ -1146,7 +1146,7 @@ class GlancesPluginModel(object):
|
|||
"""
|
||||
|
||||
def wrapper(self, *args, **kw):
|
||||
if self.is_enable() and (self.refresh_timer.finished() or self.stats == self.get_init_value):
|
||||
if self.is_enabled() and (self.refresh_timer.finished() or self.stats == self.get_init_value):
|
||||
# Run the method
|
||||
ret = fct(self, *args, **kw)
|
||||
# Reset the timer
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ class PluginModel(GlancesPluginModel):
|
|||
ret = []
|
||||
|
||||
# Only process if stats exist...
|
||||
if not self.stats or self.is_disable():
|
||||
if not self.stats or self.is_disabled():
|
||||
return ret
|
||||
|
||||
# Define the data: Bar (default behavor) or Sparkline
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class PluginModel(GlancesPluginModel):
|
|||
ret = []
|
||||
|
||||
# Only process if stats exist...
|
||||
if not self.stats or self.is_disable():
|
||||
if not self.stats or self.is_disabled():
|
||||
return ret
|
||||
|
||||
# Max size for the interface name
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ class PluginModel(GlancesPluginModel):
|
|||
ret = []
|
||||
|
||||
# Only process if stats exist and display plugin enable...
|
||||
if not self.stats or self.is_disable():
|
||||
if not self.stats or self.is_disabled():
|
||||
return ret
|
||||
|
||||
# Max size for the interface name
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ class PluginModel(GlancesPluginModel):
|
|||
ret = []
|
||||
|
||||
# Only process if stats exist...
|
||||
if import_error_tag or not self.stats or self.is_disable():
|
||||
if import_error_tag or not self.stats or self.is_disabled():
|
||||
return ret
|
||||
|
||||
# Max size for the interface name
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ class PluginModel(GlancesPluginModel):
|
|||
ret = []
|
||||
|
||||
# Only process if stats exist and display plugin enable...
|
||||
if not self.stats or import_error_tag or self.is_disable():
|
||||
if not self.stats or import_error_tag or self.is_disabled():
|
||||
return ret
|
||||
|
||||
# Max size for the interface name
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ class GlancesStats(object):
|
|||
Return: list of plugin name
|
||||
"""
|
||||
if enable:
|
||||
return [p for p in self._plugins if self._plugins[p].is_enable()]
|
||||
return [p for p in self._plugins if self._plugins[p].is_enabled()]
|
||||
else:
|
||||
return [p for p in self._plugins]
|
||||
|
||||
|
|
@ -233,7 +233,7 @@ class GlancesStats(object):
|
|||
# For standalone and server modes
|
||||
# For each plugins, call the update method
|
||||
for p in self._plugins:
|
||||
if self._plugins[p].is_disable():
|
||||
if self._plugins[p].is_disabled():
|
||||
# If current plugin is disable
|
||||
# then continue to next plugin
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ class GlancesStatsClientSNMP(GlancesStats):
|
|||
"""Update the stats using SNMP."""
|
||||
# For each plugins, call the update method
|
||||
for p in self._plugins:
|
||||
if self._plugins[p].is_disable():
|
||||
if self._plugins[p].is_disabled():
|
||||
# If current plugin is disable
|
||||
# then continue to next plugin
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class GlancesStatsServer(GlancesStats):
|
|||
def _set_stats(self, input_stats):
|
||||
"""Set the stats to the input_stats one."""
|
||||
# Build the all_stats with the get_raw() method of the plugins
|
||||
return {p: self._plugins[p].get_raw() for p in self._plugins if self._plugins[p].is_enable()}
|
||||
return {p: self._plugins[p].get_raw() for p in self._plugins if self._plugins[p].is_enabled()}
|
||||
|
||||
def getAll(self):
|
||||
"""Return the stats as a list."""
|
||||
|
|
|
|||
Loading…
Reference in New Issue