24 database. This works on Windows as long as USERNAME is set. |
24 database. This works on Windows as long as USERNAME is set. |
25 |
25 |
26 @return username |
26 @return username |
27 @rtype str |
27 @rtype str |
28 """ |
28 """ |
29 # this is copied from the oroginal getpass.py |
29 # this is copied from the original getpass.py |
30 |
30 |
31 import os |
31 import os |
32 |
32 |
33 for name in ('LOGNAME', 'USER', 'LNAME', 'USERNAME'): |
33 for name in ('LOGNAME', 'USER', 'LNAME', 'USERNAME'): |
34 user = os.environ.get(name) |
34 user = os.environ.get(name) |
38 # If this fails, the exception will "explain" why |
38 # If this fails, the exception will "explain" why |
39 import pwd |
39 import pwd |
40 return pwd.getpwuid(os.getuid())[0] |
40 return pwd.getpwuid(os.getuid())[0] |
41 |
41 |
42 |
42 |
43 def getpass(prompt='Password: '): |
43 def getpass(prompt='Password: ', stream=None): |
44 """ |
44 """ |
45 Function to prompt for a password, with echo turned off. |
45 Function to prompt for a password, with echo turned off. |
46 |
46 |
47 @param prompt Prompt to be shown to the user |
47 @param prompt Prompt to be shown to the user |
48 @type str |
48 @type str |
|
49 @param stream input stream to read from (ignored) |
|
50 @type file |
49 @return Password entered by the user |
51 @return Password entered by the user |
50 @rtype str |
52 @rtype str |
51 """ |
53 """ |
52 return input(prompt, False) # secok |
54 return input(prompt, False) # secok |
53 |
55 |
54 |
56 |
55 unix_getpass = getpass |
57 unix_getpass = getpass |
56 win_getpass = getpass |
58 win_getpass = getpass |
57 default_getpass = getpass |
59 default_getpass = getpass |
58 fallback_getpass = getpass |
60 fallback_getpass = getpass |