Catch KeyError on uid and gid conversion
This commit is contained in:
parent
0245f382ba
commit
bc48175929
1 changed files with 8 additions and 2 deletions
10
smem
10
smem
|
|
@ -62,13 +62,19 @@ class procdata(object):
|
||||||
if uid == -1:
|
if uid == -1:
|
||||||
return '?'
|
return '?'
|
||||||
if uid not in self._ucache:
|
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]
|
return self._ucache[uid]
|
||||||
def groupname(self, gid):
|
def groupname(self, gid):
|
||||||
if gid == -1:
|
if gid == -1:
|
||||||
return '?'
|
return '?'
|
||||||
if gid not in self._gcache:
|
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]
|
return self._gcache[gid]
|
||||||
|
|
||||||
class tardata(procdata):
|
class tardata(procdata):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue