Skip to content

Commit

Permalink
uid2name :: fix situations where uid of file does not actually exist …
Browse files Browse the repository at this point in the history
…in the system
  • Loading branch information
adriansev committed Oct 16, 2024
1 parent 26939ea commit 4b05cd3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion alienpy/tools_nowb.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,11 @@ def get_arg_multiple(target: list, item: str) -> list:

def uid2name(uid: Union[str, int]) -> str:
"""Convert numeric UID to username"""
return pwd.getpwuid(int(uid)).pw_name
try:
user_info = pwd.getpwuid(int(uid))
return user_info.pw_name
except Exception:
return str(uid)


def gid2name(gid: Union[str, int]) -> str:
Expand Down

0 comments on commit 4b05cd3

Please sign in to comment.