Fix ps -t output in windows

This commit is contained in:
Oleksii Shevchuk 2017-03-16 17:50:22 +02:00
parent 1671950b3a
commit 3db9dcd9ec
1 changed files with 3 additions and 1 deletions

View File

@ -15,7 +15,7 @@ def gen_columns(record, colinfo):
columns['name'] = record.get('name') or '?' columns['name'] = record.get('name') or '?'
columns['cmdline'] = ' '.join([ columns['cmdline'] = ' '.join([
x for x in record['cmdline'][1:] if x.strip() x for x in record['cmdline'][1:] if x.strip()
]) if 'cmdline' in record else '' ]) if record.get('cmdline') else ''
columns['exe'] = record.get('exe') or '{{{}}}'.format(columns['name']) columns['exe'] = record.get('exe') or '{{{}}}'.format(columns['name'])
columns['username'] = record.get('username') or '' columns['username'] = record.get('username') or ''
cpu = record.get('cpu_percent') cpu = record.get('cpu_percent')
@ -92,6 +92,7 @@ def print_pstree(fout, parent, tree, data,
prefix=indent+('' if first else ''), indent=indent + '', width=width, prefix=indent+('' if first else ''), indent=indent + '', width=width,
colinfo=colinfo, info=info, hide=hide colinfo=colinfo, info=info, hide=hide
) )
first = False
child = tree[parent][-1] child = tree[parent][-1]
print_pstree( print_pstree(
@ -123,6 +124,7 @@ class PsModule(PupyModule):
""" list processes """ """ list processes """
dependencies = [ 'pupyps' ] dependencies = [ 'pupyps' ]
is_module=False
def init_argparse(self): def init_argparse(self):
self.arg_parser = PupyArgumentParser(prog="ps", description=self.__doc__) self.arg_parser = PupyArgumentParser(prog="ps", description=self.__doc__)