Skip to content

Commit 28ae98d

Browse files
authored
Handle no tty pwinput (#8296)
* Handle no tty pwinput Pwinput : When terminal / tty is not available, read from stdin * update version * fix lint issue
1 parent 8d5bfbd commit 28ae98d

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

src/connectedvmware/HISTORY.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
33
Release History
44
===============
5+
1.2.1
6+
++++++
7+
* For pwinput, read input from stdin when tty is not available
8+
59
1.2.0
610
++++++
711
* Add support to enable a VM using managed object name (moName).

src/connectedvmware/azext_connectedvmware/custom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ def create_from_machines(
888888
for vm in vm_list:
889889
biosId2VM[vm["biosId"]].append(vm)
890890
for i, vm in enumerate(vm_list):
891-
prefix = f"[{i+1}/{len(vm_list)}]"
891+
prefix = f"[{i + 1}/{len(vm_list)}]"
892892
machineId = vm["machineId"]
893893
machineName = vm["name"]
894894
machineRG = vm["resourceGroup"]

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

src/connectedvmware/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# TODO: Confirm this is the right version number you want and it matches your
2020
# HISTORY.rst entry.
2121

22-
VERSION = '1.2.0'
22+
VERSION = '1.2.1'
2323

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

0 commit comments

Comments
 (0)