baweaver / psutil

Automatically exported from code.google.com/p/psutil
Other
0 stars 0 forks source link

Add Process.as_dict() utility method #278

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
This is something which comes up every now and then: an utility method which 
returns an hashable dictionary containing all the process information.
Usually, the user of this method intends to collect all process info in one 
shot and possibly pass the obtained data via json or similar data formats.
In general, this results in writing less and more-compact code since one 
doesn't have to look for AccessDenied exception every time as in:

p = psutil.Process(pid)
try:
    cwd = p.getcwd
except psutil.AccessDenied:
    cwd = None
try:
    ppid = p.ppid
except psutil.AccessDenied:
    ppid = None

...vs:

p = psutil.Process(pid)
data = p.as_dict()
cwd = data['cwd']
ppid = data['ppid']

This is now committed in r1341.

Original issue reported on code.google.com by g.rodola on 10 Jun 2012 at 9:59

GoogleCodeExporter commented 8 years ago

Original comment by g.rodola on 10 Jun 2012 at 10:08

GoogleCodeExporter commented 8 years ago

Original comment by g.rodola on 13 Jun 2012 at 2:08

GoogleCodeExporter commented 8 years ago
0.5.0 is finally out. Closing out as fixed.

Original comment by g.rodola on 27 Jun 2012 at 6:54

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Updated csets after the SVN -> Mercurial migration:
r1341 == revision ???

Original comment by g.rodola on 2 Mar 2013 at 12:08