From 8f64c765e007d45d5e6d7d7f7e4636cf649baf25 Mon Sep 17 00:00:00 2001 From: Oleksii Shevchuk Date: Thu, 16 Mar 2017 21:36:33 +0200 Subject: [PATCH] Minor fixes in ps module --- pupy/modules/ps.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pupy/modules/ps.py b/pupy/modules/ps.py index 46be303e..570a72c6 100644 --- a/pupy/modules/ps.py +++ b/pupy/modules/ps.py @@ -54,7 +54,8 @@ def gen_output_line(columns, info, record, width): template = ' '.join('{{{}}}'.format(x) for x in info) output = template.format(**columns) if width: - output = output[:width] + diff = len(output) - len(output.decode('utf-8', 'replace')) + output = output[:width+diff] if color: output = colorize(output, color) @@ -164,9 +165,6 @@ class PsModule(PupyModule): hide = [ int(x) if x.isdigit() else x for x in args.hide ] - show = [ - int(x) if x.isdigit() else x for x in args.show - ] if not args.all and self.client.is_linux(): hide.append(2) @@ -175,7 +173,7 @@ class PsModule(PupyModule): info = [ 'username', 'cpu_percent', 'memory_percent' ] + info if args.tree: - show = show or [ root ] + show = args.show or [ root ] for item in show: print_pstree( @@ -184,7 +182,10 @@ class PsModule(PupyModule): hide=hide, first=(item == root) ) else: - data = [ x for x in data if x in args.show ] if args.show else data + data = { + x:y for x,y in data.iteritems() if x in args.show + } if args.show else data + print_ps( self.stdout, data, width=None if args.wide else width, colinfo=colinfo, info=info, hide=hide