Try and catch to solve AccessDenied on username stat on Windows 7

pull/146/head
Nicolas Hennion 2012-12-13 12:24:53 +01:00
parent 73c30932dd
commit 8dc626dae6
1 changed files with 6 additions and 1 deletions

View File

@ -487,13 +487,18 @@ class GlancesGrabProcesses:
procstat['io_counters'] = {}
procstat['pid'] = proc.pid
procstat['username'] = proc.username
try:
procstat['username'] = proc.username
except psutil.AccessDenied, err:
procstat['username'] = ""
pass
if hasattr(proc, 'get_nice'):
# Deprecated in PsUtil 0.5.0+
try:
procstat['nice'] = proc.get_nice()
except psutil.AccessDenied, err:
procstat['nice'] = 0
pass
elif hasattr(proc, 'nice'):
# Else