Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle no tty pwinput #8296

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/connectedvmware/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Release History
===============
1.2.1
++++++
* For pwinput, read input from stdin when tty is not available

1.2.0
++++++
* Add support to enable a VM using managed object name (moName).
Expand Down
5 changes: 4 additions & 1 deletion src/connectedvmware/azext_connectedvmware/pwinput.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
except ImportError:
pass # There is no typing module on Python 2, but that's fine because we use the comment-style of type hints.

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

Expand Down
2 changes: 1 addition & 1 deletion src/connectedvmware/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# TODO: Confirm this is the right version number you want and it matches your
# HISTORY.rst entry.

VERSION = '1.2.0'
VERSION = '1.2.1'

# The full list of classifiers is available at
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
Expand Down
Loading