1
0
mirror of https://github.com/altlinux/gpupdate.git synced 2025-03-21 18:50:38 +03:00

Added functions get_uid_by_username

This commit is contained in:
Valery Sinelnikov 2023-07-25 17:52:13 +04:00
parent 28e2d9c94b
commit e6a51d02fb

View File

@ -180,3 +180,9 @@ def touch_file(filename):
path.parent.mkdir(parents=True, exist_ok=True)
path.touch()
def get_uid_by_username(username):
try:
user_info = pwd.getpwnam(username)
return user_info.pw_uid
except KeyError:
return None