Hi, all
When running the sample at ArcGIS Help (10.2, 10.2.1, and 10.2.2) , does anyone have this issue?
Using getpass in python console widget echos password in Windows (Python 2.7 or earlier)
The code is attached.
+++++++++++++++
What steps will reproduce the problem?
1.Open a python interpreter in the console
2.type the following:
>>> import getpass
>>> notMyPassword = getpass.getpass("type your password: ")
password
What is the expected output?
It shows the prompt "don't type your password: " but the password characters are not echoed to the console window
What do you see instead?
getpass displays a warning that it couldn't control echo on the terminal, and that password input may be echoed.
The getpass documentation states:
getpass.getpass([prompt[, stream]])
Prompt the user for a password without echoing. The user is prompted using the string prompt, which defaults to'Password: '. On Unix, the prompt is written to the file-like object stream. stream defaults to the controlling terminal (/dev/tty) or if that is unavailable to sys.stderr (this argument is ignored on Windows).
If echo free input is unavailable getpass() falls back to printing
a warning message to stream and reading from sys.stdinand issuing a GetPassWarning.
From what you describe, it seems your code is working as expected. Are you on Windows or Linux?
JB,
Did you reproduce this issue?
As expected, using getpass in python echos password in Windows (Python 2.7 or earlier), that is, a UserWarning subclass issued.
10.1 | 10.2.2 |
---|---|
Warning (from warnings module): File "C:\Python27\ArcGIS10.1\lib\getpass.py", line 92 return fallback_getpass(prompt, stream) GetPassWarning: Can not control echo on the terminal. Warning: Password input may be echoed. Enter password: | Warning: Password input may be echoed Enter password: |
The same issu is applied to all scrips, when using getpass, for example, start a service by starting the geometry service at ArcGIS Help (10.2, 10.2.1, and 10.2.2)
Didn't try 10.3 Prerelease (I guess, the issue exist because 10.3 uses still Python 2.7). I tested with 3.4, which is fine in Python 3.4 (that ArcGIS Pro uses).
Keep in mind, if we directly run the code like username=getpass.getuser() OR username = raw_input("Enter user name: "), it would be fine. Pls check at https://community.esri.com/message/284618#284618
Of course, if input without using 'getpass', the example works.
I am running ArcGIS 10.2.2 with Python 2.7.5 on Windows 7 Enterprise x64, and I am able to get your attached script to run from a command prompt with no warnings and no errors, i.e., everything works as one would expect from reading documentation. If I try to run the script from within an IDE, e.g., IDLE or PyCharm, then I get the warning about echoed passwords and they are echoed.