From 1c1b9ef9277d6c67b62b7c0c79add42214865867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Sat, 2 Apr 2016 17:09:13 +0200 Subject: [PATCH] Detect TTY when deciding whether to enable interactive mode or not --- pyicloud/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyicloud/utils.py b/pyicloud/utils.py index 1c08c92..8981d30 100644 --- a/pyicloud/utils.py +++ b/pyicloud/utils.py @@ -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: