mirror of
https://github.com/nicolargo/glances.git
synced 2026-03-15 04:16:22 -04:00
Fix highlighting of process when it contains whitespaces (issue #546)
This commit is contained in:
@@ -290,22 +290,22 @@ class Plugin(GlancesPlugin):
|
|||||||
# If no command line for the process is available, fallback to
|
# If no command line for the process is available, fallback to
|
||||||
# the bare process name instead
|
# the bare process name instead
|
||||||
cmdline = p['cmdline']
|
cmdline = p['cmdline']
|
||||||
argument = ' '.join(cmdline.split()[1:])
|
|
||||||
try:
|
try:
|
||||||
if cmdline == '':
|
# XXX: remove `cmdline != ['']` when we'll drop support for psutil<4.0.0
|
||||||
msg = ' {0}'.format(p['name'])
|
if cmdline and cmdline != ['']:
|
||||||
ret.append(self.curse_add_line(msg, splittable=True))
|
path, cmd = os.path.split(cmdline[0])
|
||||||
else:
|
|
||||||
cmd = cmdline.split()[0]
|
|
||||||
path, basename = os.path.split(cmd)
|
|
||||||
if os.path.isdir(path) and not args.process_short_name:
|
if os.path.isdir(path) and not args.process_short_name:
|
||||||
msg = ' {0}'.format(path) + os.sep
|
msg = ' {0}'.format(path) + os.sep
|
||||||
ret.append(self.curse_add_line(msg, splittable=True))
|
ret.append(self.curse_add_line(msg, splittable=True))
|
||||||
ret.append(self.curse_add_line(basename, decoration='PROCESS', splittable=True))
|
ret.append(self.curse_add_line(cmd, decoration='PROCESS', splittable=True))
|
||||||
else:
|
else:
|
||||||
msg = ' {0}'.format(basename)
|
msg = ' {0}'.format(cmd)
|
||||||
ret.append(self.curse_add_line(msg, decoration='PROCESS', splittable=True))
|
ret.append(self.curse_add_line(msg, decoration='PROCESS', splittable=True))
|
||||||
msg = ' {0}'.format(argument)
|
arguments = ' '.join(cmdline[1:]).replace('\n', ' ')
|
||||||
|
msg = ' {0}'.format(arguments)
|
||||||
|
ret.append(self.curse_add_line(msg, splittable=True))
|
||||||
|
else:
|
||||||
|
msg = ' {0}'.format(p['name'])
|
||||||
ret.append(self.curse_add_line(msg, splittable=True))
|
ret.append(self.curse_add_line(msg, splittable=True))
|
||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
ret.append(self.curse_add_line('', splittable=True))
|
ret.append(self.curse_add_line('', splittable=True))
|
||||||
|
|||||||
@@ -392,8 +392,7 @@ class GlancesProcesses(object):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
# Patch for issue #391
|
# Patch for issue #391
|
||||||
try:
|
try:
|
||||||
self.cmdline_cache[
|
self.cmdline_cache[procstat['pid']] = proc.cmdline()
|
||||||
procstat['pid']] = ' '.join(proc.cmdline())
|
|
||||||
except (AttributeError, UnicodeDecodeError, psutil.AccessDenied, psutil.NoSuchProcess):
|
except (AttributeError, UnicodeDecodeError, psutil.AccessDenied, psutil.NoSuchProcess):
|
||||||
self.cmdline_cache[procstat['pid']] = ""
|
self.cmdline_cache[procstat['pid']] = ""
|
||||||
procstat['cmdline'] = self.cmdline_cache[procstat['pid']]
|
procstat['cmdline'] = self.cmdline_cache[procstat['pid']]
|
||||||
|
|||||||
Reference in New Issue
Block a user