Catch KeyError on uid and gid conversion
This commit is contained in:
parent
31daff485e
commit
4701e3a741
1 changed files with 8 additions and 2 deletions
10
smem
10
smem
|
|
@ -62,13 +62,19 @@ class procdata(object):
|
|||
if uid == -1:
|
||||
return '?'
|
||||
if uid not in self._ucache:
|
||||
self._ucache[uid] = pwd.getpwuid(uid)[0]
|
||||
try:
|
||||
self._ucache[uid] = pwd.getpwuid(uid)[0]
|
||||
except KeyError:
|
||||
self._ucache[uid] = uid
|
||||
return self._ucache[uid]
|
||||
def groupname(self, gid):
|
||||
if gid == -1:
|
||||
return '?'
|
||||
if gid not in self._gcache:
|
||||
self._gcache[gid] = pwd.getgrgid(gid)[0]
|
||||
try:
|
||||
self._gcache[gid] = pwd.getgrgid(gid)[0]
|
||||
except KeyError:
|
||||
self._gcache[gid] = gid
|
||||
return self._gcache[gid]
|
||||
|
||||
class tardata(procdata):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue