Skip to content

Commit c2b232c

Browse files
authored
Handle no tty pwinput
Pwinput : When terminal / tty is not available, read from stdin
1 parent eb8290c commit c2b232c

File tree

1 file changed

+4
-1
lines changed
  • src/connectedvmware/azext_connectedvmware

1 file changed

+4
-1
lines changed

src/connectedvmware/azext_connectedvmware/pwinput.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@
3434
except ImportError:
3535
pass # There is no typing module on Python 2, but that's fine because we use the comment-style of type hints.
3636

37-
if sys.platform == 'win32':
37+
if not sys.stdin.isatty():
38+
def pwinput(prompt='Password: ', mask='*'):
39+
return sys.stdin.readline().rstrip()
40+
elif sys.platform == 'win32':
3841
# For some reason, mypy reports that msvcrt doesn't have getch, ignore this warning:
3942
from msvcrt import getch # type: ignore
4043

0 commit comments

Comments
 (0)