Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Process.as_dict() utility method #278

Closed
giampaolo opened this issue May 23, 2014 · 4 comments
Closed

Add Process.as_dict() utility method #278

giampaolo opened this issue May 23, 2014 · 4 comments

Comments

@giampaolo
Copy link
Owner

From g.rodola on June 10, 2012 23:59:25

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: http://code.google.com/p/psutil/issues/detail?id=278

@giampaolo giampaolo self-assigned this May 23, 2014
@giampaolo
Copy link
Owner Author

From g.rodola on June 10, 2012 15:08:45

Status: FixedInSVN

@giampaolo
Copy link
Owner Author

From g.rodola on June 13, 2012 07:08:47

Cc: luca.ope...@gmail.com

@giampaolo
Copy link
Owner Author

From g.rodola on June 27, 2012 11:54:03

0.5.0 is finally out. Closing out as fixed.

Status: Fixed

@giampaolo
Copy link
Owner Author

From g.rodola on March 02, 2013 04:08:51

Updated csets after the SVN -> Mercurial migration: r1341 == revision ???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant