mirror of https://github.com/nicolargo/glances.git
Newline in container command corrupts display / hides container #2733
This commit is contained in:
parent
ade83ac0cc
commit
ccd5094782
|
|
@ -436,3 +436,9 @@ def namedtuple_to_dict(data):
|
|||
def list_of_namedtuple_to_list_of_dict(data):
|
||||
"""Convert a list of namedtuples to a dict, using the _asdict() method embeded in PsUtil stats."""
|
||||
return [namedtuple_to_dict(d) for d in data]
|
||||
|
||||
|
||||
def replace_special_chars(input_string, by=' '):
|
||||
"""Replace some special char by another in the input_string
|
||||
Return: the string with the chars replaced"""
|
||||
return input_string.replace('\r\n', by).replace('\n', by).replace('\t', by)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
"""Docker Extension unit for Glances' Containers plugin."""
|
||||
import time
|
||||
|
||||
from glances.globals import iterkeys, itervalues, nativestr, pretty_date
|
||||
from glances.globals import iterkeys, itervalues, nativestr, pretty_date, replace_special_chars
|
||||
from glances.logger import logger
|
||||
from glances.plugins.containers.stats_streamer import StatsStreamer
|
||||
|
||||
|
|
@ -334,7 +334,7 @@ class DockerContainersExtension:
|
|||
stats['network_rx'] = stats['network'].get('rx') // stats['network'].get('time_since_update')
|
||||
stats['network_tx'] = stats['network'].get('tx') // stats['network'].get('time_since_update')
|
||||
stats['uptime'] = pretty_date(parser.parse(started_at).astimezone(tz.tzlocal()).replace(tzinfo=None))
|
||||
stats['command'] = ' '.join(stats['command'])
|
||||
stats['command'] = replace_special_chars(' '.join(stats['command']))
|
||||
else:
|
||||
stats['io'] = {}
|
||||
stats['cpu'] = {}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
"""Podman Extension unit for Glances' Containers plugin."""
|
||||
from datetime import datetime
|
||||
|
||||
from glances.globals import iterkeys, itervalues, nativestr, pretty_date, string_value_to_float
|
||||
from glances.globals import iterkeys, itervalues, nativestr, pretty_date, string_value_to_float, replace_special_chars
|
||||
from glances.logger import logger
|
||||
from glances.plugins.containers.stats_streamer import StatsStreamer
|
||||
|
||||
|
|
@ -334,7 +334,8 @@ class PodmanContainersExtension:
|
|||
stats['network_rx'] = stats['network'].get('rx') // stats['network'].get('time_since_update')
|
||||
stats['network_tx'] = stats['network'].get('tx') // stats['network'].get('time_since_update')
|
||||
stats['uptime'] = pretty_date(started_at)
|
||||
stats['command'] = ' '.join(stats['command'])
|
||||
# Manage special chars in command (see isse#2733)
|
||||
stats['command'] = replace_special_chars(' '.join(stats['command']))
|
||||
else:
|
||||
stats['io'] = {}
|
||||
stats['cpu'] = {}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import os
|
|||
import copy
|
||||
|
||||
from glances.logger import logger
|
||||
from glances.globals import WINDOWS, key_exist_value_not_none_not_v
|
||||
from glances.globals import WINDOWS, key_exist_value_not_none_not_v, replace_special_chars
|
||||
from glances.processes import glances_processes, sort_stats
|
||||
from glances.outputs.glances_unicode import unicode_message
|
||||
from glances.plugins.core import PluginModel as CorePluginModel
|
||||
|
|
@ -487,9 +487,7 @@ class PluginModel(GlancesPluginModel):
|
|||
if cmdline:
|
||||
path, cmd, arguments = split_cmdline(bare_process_name, cmdline)
|
||||
# Manage end of line in arguments (see #1692)
|
||||
arguments = arguments.replace('\r\n', ' ')
|
||||
arguments = arguments.replace('\n', ' ')
|
||||
arguments = arguments.replace('\t', ' ')
|
||||
arguments = replace_special_chars(arguments)
|
||||
if os.path.isdir(path) and not args.process_short_name:
|
||||
msg = self.layout_stat['command'].format(path) + os.sep
|
||||
ret.append(self.curse_add_line(msg, splittable=True))
|
||||
|
|
|
|||
Loading…
Reference in New Issue