mirror of
https://github.com/nicolargo/glances.git
synced 2024-12-27 19:25:27 +03:00
Use Python 2.6 compatible string.format calls (closes #633)
This commit is contained in:
parent
e116ff4d45
commit
afe5e6c7f2
@ -70,11 +70,11 @@ class GlancesExport(object):
|
||||
'docker']
|
||||
|
||||
def get_item_key(self, item):
|
||||
"""Return the value of the item 'key'"""
|
||||
"""Return the value of the item 'key'."""
|
||||
try:
|
||||
ret = item[item['key']]
|
||||
except KeyError:
|
||||
logger.error("No 'key' available in {}".format(item))
|
||||
logger.error("No 'key' available in {0}".format(item))
|
||||
if isinstance(ret, list):
|
||||
return ret[0]
|
||||
else:
|
||||
@ -112,7 +112,7 @@ class GlancesExport(object):
|
||||
return True
|
||||
|
||||
def __build_export(self, stats):
|
||||
"""Build the export lists"""
|
||||
"""Build the export lists."""
|
||||
export_names = []
|
||||
export_values = []
|
||||
|
||||
@ -120,7 +120,7 @@ class GlancesExport(object):
|
||||
# Stats is a dict
|
||||
# Is there a key ?
|
||||
if 'key' in list(stats.keys()):
|
||||
pre_key = '{}.'.format(stats[stats['key']])
|
||||
pre_key = '{0}.'.format(stats[stats['key']])
|
||||
else:
|
||||
pre_key = ''
|
||||
# Walk through the dict
|
||||
|
@ -146,7 +146,7 @@ class Export(GlancesExport):
|
||||
|
||||
def export(self, name, columns, points):
|
||||
"""Write the points to the InfluxDB server."""
|
||||
logger.debug("Export {} stats to InfluxDB".format(name))
|
||||
logger.debug("Export {0} stats to InfluxDB".format(name))
|
||||
# Manage prefix
|
||||
if self.prefix is not None:
|
||||
name = self.prefix + '.' + name
|
||||
@ -162,4 +162,4 @@ class Export(GlancesExport):
|
||||
try:
|
||||
self.client.write_points(data)
|
||||
except Exception as e:
|
||||
logger.error("Can not export {} stats to InfluxDB ({})".format(name, e))
|
||||
logger.error("Cannot export {0} stats to InfluxDB ({1})".format(name, e))
|
||||
|
@ -100,4 +100,4 @@ class Export(GlancesExport):
|
||||
self.client.gauge(stat_name, stat_value)
|
||||
except Exception as e:
|
||||
logger.error("Can not export stats to Statsd (%s)" % e)
|
||||
logger.debug("Export {} stats to Statsd".format(name))
|
||||
logger.debug("Export {0} stats to Statsd".format(name))
|
||||
|
@ -1020,7 +1020,7 @@ class GlancesCursesBrowser(_GlancesCurses):
|
||||
servers_list: Dict of dict with servers stats
|
||||
"""
|
||||
# Flush display
|
||||
logger.debug("Servers list: {}".format(servers_list))
|
||||
logger.debug('Servers list: {0}'.format(servers_list))
|
||||
self.flush(servers_list)
|
||||
|
||||
# Wait
|
||||
|
@ -65,7 +65,8 @@ class Plugin(GlancesPlugin):
|
||||
return 'name'
|
||||
|
||||
def get_export(self):
|
||||
"""Overwrite the default export method
|
||||
"""Overwrite the default export method.
|
||||
|
||||
- Only exports containers
|
||||
- The key is the first container name
|
||||
"""
|
||||
@ -73,7 +74,7 @@ class Plugin(GlancesPlugin):
|
||||
try:
|
||||
ret = self.stats['containers']
|
||||
except KeyError as e:
|
||||
logger.debug("Docker export error {}".format(e))
|
||||
logger.debug("Docker export error {0}".format(e))
|
||||
return ret
|
||||
|
||||
def connect(self, version=None):
|
||||
@ -180,10 +181,10 @@ class Plugin(GlancesPlugin):
|
||||
# Create the stats instance for the current container
|
||||
try:
|
||||
self.docker_stats[c['Id']] = self.docker_client.stats(c['Id'], decode=True)
|
||||
logger.debug("Create Docker stats object for container {}".format(c['Id']))
|
||||
logger.debug("Create Docker stats object for container {0}".format(c['Id']))
|
||||
except Exception as e:
|
||||
# Correct Issue #602
|
||||
logger.error("Can not call Docker stats method {}".format(e))
|
||||
logger.error("Cannot call Docker stats method {0}".format(e))
|
||||
|
||||
# Get the docker stats
|
||||
try:
|
||||
@ -365,7 +366,7 @@ class Plugin(GlancesPlugin):
|
||||
# By storing time data we enable Rx/s and Tx/s calculations in the
|
||||
# XML/RPC API, which would otherwise be overly difficult work
|
||||
# for users of the API
|
||||
network_new['time_since_update'] = getTimeSinceLastUpdate('docker_net_{}'.format(container_id))
|
||||
network_new['time_since_update'] = getTimeSinceLastUpdate('docker_net_{0}'.format(container_id))
|
||||
network_new['rx'] = netiocounters["rx_bytes"] - self.netiocounters_old[container_id]["rx_bytes"]
|
||||
network_new['tx'] = netiocounters["tx_bytes"] - self.netiocounters_old[container_id]["tx_bytes"]
|
||||
network_new['cumulative_rx'] = netiocounters["rx_bytes"]
|
||||
|
@ -112,7 +112,7 @@ class Plugin(GlancesPlugin):
|
||||
ret.append(self.curse_add_line(msg, status))
|
||||
elif self.stats[array]['status'] == 'inactive':
|
||||
ret.append(self.curse_new_line())
|
||||
msg = '└─ Status {}'.format(self.stats[array]['status'])
|
||||
msg = '└─ Status {0}'.format(self.stats[array]['status'])
|
||||
ret.append(self.curse_add_line(msg, status))
|
||||
components = self.stats[array]['components'].keys()
|
||||
components.sort()
|
||||
|
Loading…
Reference in New Issue
Block a user