From 4ef665a7cc1af14814f9cade3768b64447a6542f Mon Sep 17 00:00:00 2001 From: Ken Thomas Date: Thu, 1 Mar 2012 13:09:23 -0800 Subject: [PATCH] Glance skip prompting if stdin isn't a tty Don't have glance issue prompts if stdin isn't a tty. Fixes bug 884116. In glance's user_confirm routine, check if stdin is a tty and if not, just return the default value. If it is a tty, then continue with the raw_input call to issue the prompt and get the response. Latest patch includes recommended change to check for isatty attr before using it. Added myself to Authors. Change-Id: I8134668b8382b44618c86972190f3d7d98f55e52 --- Authors | 1 + bin/glance | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Authors b/Authors index 8d096389..cb2b6a0a 100644 --- a/Authors +++ b/Authors @@ -27,6 +27,7 @@ Josh Kearney Justin Santa Barbara Justin Shepherd Ken Pepple +Ken Thomas Kevin L. Mitchell Lorin Hochstein Major Hayden diff --git a/bin/glance b/bin/glance index 51d62a5f..35b68253 100755 --- a/bin/glance +++ b/bin/glance @@ -999,6 +999,10 @@ def user_confirm(prompt, default=False): else: prompt_default = "[y/N]" + # for bug 884116, don't issue the prompt if stdin isn't a tty + if not hasattr(sys.stdin, 'isatty') or not sys.stdin.isatty(): + return default + answer = raw_input("%s %s " % (prompt, prompt_default)) if answer == "":