From 092eda183c9709336511a742fff59c62407cbcac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Saugat=20Pachhai=20=28=E0=A4=B8=E0=A5=8C=E0=A4=97=E0=A4=BE?= =?UTF-8?q?=E0=A4=A4=29?= Date: Tue, 17 May 2022 15:54:56 +0545 Subject: [PATCH] objects.fs: use getpass for prompts Note that this will change the behaviour of DVC to always show prompt even in --quiet mode, which is what we need. Previously it'd prompt without any message. --- dvc/objects/fs/implementations/http.py | 7 ++----- dvc/objects/fs/implementations/ssh.py | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/dvc/objects/fs/implementations/http.py b/dvc/objects/fs/implementations/http.py index 1ae775f66..102291f74 100644 --- a/dvc/objects/fs/implementations/http.py +++ b/dvc/objects/fs/implementations/http.py @@ -1,9 +1,9 @@ import threading +from getpass import getpass from typing import BinaryIO, Union from funcy import cached_property, memoize, wrap_with -from dvc import prompt from dvc.scheme import Schemes from .._callback import DEFAULT_CALLBACK, FsspecCallback @@ -13,10 +13,7 @@ from ..base import AnyFSPath, FileSystem @wrap_with(threading.Lock()) @memoize def ask_password(host, user): - return prompt.password( - "Enter a password for " - "host '{host}' user '{user}'".format(host=host, user=user) - ) + return getpass(f"Enter a password for host '{host}' user '{user}':\n") def make_context(ssl_verify): diff --git a/dvc/objects/fs/implementations/ssh.py b/dvc/objects/fs/implementations/ssh.py index 9c4810488..1374c1ed3 100644 --- a/dvc/objects/fs/implementations/ssh.py +++ b/dvc/objects/fs/implementations/ssh.py @@ -4,7 +4,6 @@ import threading from funcy import cached_property, memoize, silent, wrap_prop, wrap_with -from dvc import prompt from dvc.scheme import Schemes from .._callback import DEFAULT_CALLBACK @@ -17,11 +16,9 @@ DEFAULT_PORT = 22 @wrap_with(threading.Lock()) @memoize def ask_password(host, user, port): - return prompt.password( + return getpass.getpass( "Enter a private key passphrase or a password for " - "host '{host}' port '{port}' user '{user}'".format( - host=host, port=port, user=user - ) + f"host '{host}' port '{port}' user '{user}':\n" )