joknarf / pgtree Goto Github PK
View Code? Open in Web Editor NEWUnix process hierachy tree for specific processes (mixed pgrep + pstree)
License: MIT License
Unix process hierachy tree for specific processes (mixed pgrep + pstree)
License: MIT License
Need to remove distutils
34a35,40
>
> python version restrictions:
> python 2.6 no f string
> python 2.6 no dict comprehension
> python 2.4 no inline if
> python 2.3 no fake dict comprehension
125c131,133
< self.ps_fields = psfield.split(',') if psfield else None
---
> self.ps_fields = None
> if psfield:
> self.ps_fields = psfield.split(',')
132,134c140,151
< self.ps_fields = ['start'] if osname in ['AIX', 'Darwin'] else ['stime']
< user = 'uid' if use_uid else 'user'
< comm = 'comm' if osname == 'SunOS' else 'ucomm'
---
> if osname in ['AIX', 'Darwin']:
> self.ps_fields = ['start']
> else:
> self.ps_fields = ['stime']
> if use_uid:
> user = 'uid'
> else:
> user = 'user'
> if osname == 'SunOS':
> comm = 'comm'
> else:
> comm = 'ucomm'
148,150c165,167
< infos = dict((v, line[i*131:min(i*131+130, len(line))].strip())
< for i,v in enumerate(ps_opts)
< )
---
> infos = {}
> for i,v in enumerate(ps_opts):
> infos[v] = line[i*131:min(i*131+130, len(line))].strip()
277c294,300
< self.pids = pids or ('0' if '0' in self.children else '1')
---
> if pids:
> self.pids = pids
> else:
> if '0' in self.children:
> self.pids = '0'
> else:
> self.pids = '1'
it will be nice to have an option to print process status : running, sleep, defunct...
ps_opts = ['pid', 'ppid', 'user'] + self.ps_fields + ['comm']
infos = {}
for i,v in enumerate(ps_opts):
infos[v] = line[i*131:i*131+130].strip()
infos['args'] = line[len(ps_opts)*131:len(line)]
Hi there,
Usually CLI utils supporting coloring have a way to enforce colored output apart from "no color" and "auto" (tty recognition).
This is helpful when used in watch -n1
, etc. pgtree
currently prints non-colored version, it seems.
Great little utility btw!
# pgtree -c ssh-agent
> 333 ssh-agent
443 gnome-session
> \_435 ssh-agent
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.