提交 9ba1394c 编写于 作者: N Nicolargo

Add a tag --process-short-name to force display of processes short name...

Add a tag --process-short-name to force display of processes short name instead of full path (issue #407)
上级 d617e95a
......@@ -20,7 +20,7 @@
"""Init the Glances software."""
__appname__ = 'glances'
__version__ = '2.1_RC5'
__version__ = '2.1_RC6'
__author__ = 'Nicolas Hennion <nicolas@nicolargo.com>'
__license__ = 'LGPL'
......
......@@ -111,9 +111,11 @@ class GlancesMain(object):
dest='time', help=_('set refresh time in seconds [default: {0} sec]').format(self.refresh_time))
parser.add_argument('-w', '--webserver', action='store_true', default=False,
dest='webserver', help=_('run Glances in web server mode'))
# Display (Curses) options
# Display options
parser.add_argument('-f', '--process-filter', default=None, type=str,
dest='process_filter', help=_('set the process filter patern (regular expression)'))
parser.add_argument('--process-short-name', action='store_true', default=False,
dest='process_short_name', help=_('force short name for processes name'))
parser.add_argument('-b', '--byte', action='store_true', default=False,
dest='byte', help=_('display network rate in byte per second'))
parser.add_argument('-1', '--percpu', action='store_true', default=False,
......
......@@ -24,7 +24,7 @@ import os
from datetime import timedelta
# Import Glances libs
from glances.core.glances_globals import glances_processes, is_linux, is_bsd, is_mac, is_windows
from glances.core.glances_globals import glances_processes, is_linux, is_bsd, is_mac, is_windows, logger
from glances.plugins.glances_plugin import GlancesPlugin
......@@ -218,13 +218,13 @@ class Plugin(GlancesPlugin):
# If no command line for the process is available, fallback to
# the bare process name instead
cmdline = p['cmdline']
if cmdline == "":
if cmdline == "" or args.process_short_name:
msg = ' {0}'.format(p['name'])
ret.append(self.curse_add_line(msg, splittable=True))
else:
try:
cmd = cmdline.split()[0]
args = ' '.join(cmdline.split()[1:])
argument = ' '.join(cmdline.split()[1:])
path, basename = os.path.split(cmd)
if os.path.isdir(path):
msg = ' {0}'.format(path) + os.sep
......@@ -233,7 +233,7 @@ class Plugin(GlancesPlugin):
else:
msg = ' {0}'.format(basename)
ret.append(self.curse_add_line(msg, decoration='PROCESS', splittable=True))
msg = " {0}".format(args)
msg = " {0}".format(argument)
ret.append(self.curse_add_line(msg, splittable=True))
except UnicodeEncodeError:
ret.append(self.curse_add_line("", splittable=True))
......
......@@ -135,7 +135,6 @@ class Plugin(GlancesPlugin):
for item in self.stats:
if item['value'] is not None and item['value'] != []:
logger.debug(item['value'])
# New line
ret.append(self.curse_new_line())
# Alias for the lable name ?
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册