mirror of https://github.com/nicolargo/glances.git
exports: outputs: Removed iterator helpers
Related to #3181 Signed-off-by: Boris Okassa <borisokassa@yahoo.fr>
This commit is contained in:
parent
505a90f8da
commit
ed2e1cdefb
|
|
@ -14,8 +14,6 @@ I am your father...
|
|||
from glances.globals import (
|
||||
NoOptionError,
|
||||
NoSectionError,
|
||||
iteritems,
|
||||
iterkeys,
|
||||
json_dumps,
|
||||
)
|
||||
from glances.logger import logger
|
||||
|
|
@ -266,12 +264,12 @@ class GlancesExport:
|
|||
if isinstance(stats, dict):
|
||||
# Stats is a dict
|
||||
# Is there a key ?
|
||||
if "key" in iterkeys(stats) and stats["key"] in iterkeys(stats):
|
||||
if "key" in stats.keys() and stats["key"] in stats.key():
|
||||
pre_key = "{}.".format(stats[stats["key"]])
|
||||
else:
|
||||
pre_key = ""
|
||||
# Walk through the dict
|
||||
for key, value in sorted(iteritems(stats)):
|
||||
for key, value in sorted(stats.items()):
|
||||
if isinstance(value, bool):
|
||||
value = json_dumps(value).decode()
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ class Export(GlancesExport):
|
|||
logger.debug(f"Export {name} stats to Cassandra")
|
||||
|
||||
# Remove non number stats and convert all to float (for Boolean)
|
||||
data = {k: float(v) for (k, v) in dict(zip(columns, points)).iteritems() if isinstance(v, Number)}
|
||||
data = {k: float(v) for k, v in zip(columns, points) if isinstance(v, Number)}
|
||||
|
||||
# Write input to the Cassandra table
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import pygal.style
|
|||
from pygal import DateTimeLine
|
||||
|
||||
from glances.exports.export import GlancesExport
|
||||
from glances.globals import iteritems, time_series_subsample
|
||||
from glances.globals import time_series_subsample
|
||||
from glances.logger import logger
|
||||
from glances.timer import Timer
|
||||
|
||||
|
|
@ -120,7 +120,7 @@ class Export(GlancesExport):
|
|||
x_label_rotation=20,
|
||||
x_value_formatter=lambda dt: dt.strftime('%Y/%m/%d %H:%M:%S'),
|
||||
)
|
||||
for k, v in iteritems(time_series_subsample(data, self.width)):
|
||||
for k, v in time_series_subsample(data, self.width).items():
|
||||
chart.add(k, v)
|
||||
chart.render_to_file(os.path.join(self.path, title + '.svg'))
|
||||
return True
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ from numbers import Number
|
|||
from prometheus_client import Gauge, start_http_server
|
||||
|
||||
from glances.exports.export import GlancesExport
|
||||
from glances.globals import iteritems, listkeys
|
||||
from glances.globals import listkeys
|
||||
from glances.logger import logger
|
||||
|
||||
|
||||
|
|
@ -61,10 +61,10 @@ class Export(GlancesExport):
|
|||
logger.debug(f"Export {name} stats to Prometheus exporter")
|
||||
|
||||
# Remove non number stats and convert all to float (for Boolean)
|
||||
data = {k: float(v) for (k, v) in iteritems(dict(zip(columns, points))) if isinstance(v, Number)}
|
||||
data = {k: float(v) for k, v in zip(columns, points) if isinstance(v, Number)}
|
||||
|
||||
# Write metrics to the Prometheus exporter
|
||||
for k, v in iteritems(data):
|
||||
for k, v in data.items():
|
||||
# Prometheus metric name: prefix_<glances stats name>
|
||||
metric_name = self.prefix + self.METRIC_SEPARATOR + str(name) + self.METRIC_SEPARATOR + str(k)
|
||||
# Prometheus is very sensible to the metric name
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import getpass
|
|||
import sys
|
||||
|
||||
from glances.events_list import glances_events
|
||||
from glances.globals import MACOS, WINDOWS, disable, enable, itervalues, nativestr, u
|
||||
from glances.globals import MACOS, WINDOWS, disable, enable, nativestr, u
|
||||
from glances.logger import logger
|
||||
from glances.outputs.glances_colors import GlancesColors
|
||||
from glances.outputs.glances_unicode import unicode_message
|
||||
|
|
@ -694,7 +694,7 @@ class _GlancesCurses:
|
|||
)
|
||||
|
||||
# Width of all plugins
|
||||
stats_width = sum(itervalues(plugin_widths))
|
||||
stats_width = sum(plugin_widths.values())
|
||||
|
||||
# Number of plugin but quicklook
|
||||
stats_number = sum(
|
||||
|
|
@ -720,7 +720,7 @@ class _GlancesCurses:
|
|||
logger.debug(f"Quicklook plugin not available ({e})")
|
||||
else:
|
||||
plugin_widths['quicklook'] = self.get_stats_display_width(stat_display["quicklook"])
|
||||
stats_width = sum(itervalues(plugin_widths)) + 1
|
||||
stats_width = sum(plugin_widths.values()) + 1
|
||||
self.space_between_column = 1
|
||||
self.display_plugin(stat_display["quicklook"])
|
||||
self.new_column()
|
||||
|
|
@ -741,7 +741,7 @@ class _GlancesCurses:
|
|||
if hasattr(self.args, 'disable_' + p)
|
||||
else 0
|
||||
)
|
||||
stats_width = sum(itervalues(plugin_widths)) + 1
|
||||
stats_width = sum(plugin_widths.values()) + 1
|
||||
self.space_between_column = max(
|
||||
1, int((self.term_window.getmaxyx()[1] - stats_width) / (stats_number - 1))
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue