Detect TTY when deciding whether to enable interactive mode or not

This commit is contained in:
Tor Arne Vestbø 2016-04-02 17:09:13 +02:00
parent c372797407
commit 1c1b9ef927

View file

@ -1,5 +1,6 @@
import getpass
import keyring
import sys
from .exceptions import NoStoredPasswordAvailable
@ -7,7 +8,7 @@ from .exceptions import NoStoredPasswordAvailable
KEYRING_SYSTEM = 'pyicloud://icloud-password'
def get_password(username, interactive=True):
def get_password(username, interactive=sys.stdout.isatty()):
try:
return get_password_from_keyring(username)
except NoStoredPasswordAvailable: