Correct an issue on export CPU and SENSORS

pull/1039/merge
Nicolargo 2017-02-06 16:58:40 +01:00
parent e33f11f1d5
commit 36c4269f4b
2 changed files with 38 additions and 34 deletions

View File

@ -150,21 +150,18 @@ class GlancesExport(object):
return False
# Get all the stats & limits
all_stats = stats.getAllExports()
all_limits = stats.getAllLimits()
# Get the plugins list
plugins = stats.getAllPlugins()
all_stats = stats.getAllExportsAsDict(plugin_list=self.plugins_to_export())
all_limits = stats.getAllLimitsAsDict(plugin_list=self.plugins_to_export())
# Loop over available plugins
for i, plugin in enumerate(plugins):
if plugin in self.plugins_to_export():
if isinstance(all_stats[i], dict):
all_stats[i].update(all_limits[i])
elif isinstance(all_stats[i], list):
all_stats[i] += all_limits[i]
# Loop over plugins to export
for plugin in self.plugins_to_export():
if isinstance(all_stats[plugin], dict):
all_stats[plugin].update(all_limits[plugin])
elif isinstance(all_stats[plugin], list):
all_stats[plugin] += all_limits[plugin]
else:
continue
export_names, export_values = self.__build_export(all_stats[i])
export_names, export_values = self.__build_export(all_stats[plugin])
self.export(plugin, export_names, export_values)
return True

View File

@ -186,6 +186,10 @@ class GlancesStats(object):
"""Return all the stats (list)."""
return [self._plugins[p].get_raw() for p in self._plugins]
def getAllAsDict(self):
"""Return all the stats (dict)."""
return {p: self._plugins[p].get_raw() for p in self._plugins}
def getAllExports(self):
"""
Return all the stats to be exported (list).
@ -193,25 +197,31 @@ class GlancesStats(object):
"""
return [self._plugins[p].get_export() for p in self._plugins]
def getAllAsDict(self):
"""Return all the stats (dict)."""
# Python > 2.6
# {p: self._plugins[p].get_raw() for p in self._plugins}
ret = {}
for p in self._plugins:
ret[p] = self._plugins[p].get_raw()
return ret
def getAllExportsAsDict(self, plugin_list=None):
"""
Return all the stats to be exported (list).
Default behavor is to export all the stat
if plugin_list is provided, only export stats of given plugin (list)
"""
if plugin_list is None:
# All plugins should be exported
plugin_list = self._plugins
return {p: self._plugins[p].get_export() for p in plugin_list}
def getAllLimits(self):
"""Return the plugins limits list."""
return [self._plugins[p].limits for p in self._plugins]
def getAllLimitsAsDict(self):
"""Return all the stats limits (dict)."""
ret = {}
for p in self._plugins:
ret[p] = self._plugins[p].limits
return ret
def getAllLimitsAsDict(self, plugin_list=None):
"""
Return all the stats limits (dict).
Default behavor is to export all the limits
if plugin_list is provided, only export limits of given plugin (list)
"""
if plugin_list is None:
# All plugins should be exported
plugin_list = self._plugins
return {p: self._plugins[p].limits for p in plugin_list}
def getAllViews(self):
"""Return the plugins views."""
@ -219,10 +229,7 @@ class GlancesStats(object):
def getAllViewsAsDict(self):
"""Return all the stats views (dict)."""
ret = {}
for p in self._plugins:
ret[p] = self._plugins[p].get_views()
return ret
return {p: self._plugins[p].get_views() for p in self._plugins}
def get_plugin_list(self):
"""Return the plugin list."""