-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
ensure no error when OS is not supported by pwd
- Loading branch information
Showing
3 changed files
with
28 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,25 @@ | ||
import os | ||
import pwd | ||
|
||
|
||
def pw_pair(username): | ||
pwnam = pwd.getpwnam(username) | ||
return pwnam.pw_uid, pwnam.pw_gid | ||
__all__ = ( | ||
"pw_username", | ||
"pw_pair", | ||
) | ||
|
||
|
||
def pwd(): | ||
try: | ||
import pwd | ||
|
||
return pwd | ||
except ImportError: | ||
raise OSError | ||
|
||
|
||
def system_username(): | ||
return pwd.getpwuid(os.getuid()).pw_name | ||
def pw_username(): | ||
return pwd().getpwuid(os.getuid()).pw_name | ||
|
||
|
||
def pw_pair(username): | ||
pwnam = pwd().getpwnam(username) | ||
return pwnam.pw_uid, pwnam.pw_gid |