Skip to content

Commit

Permalink
Glance skip prompting if stdin isn't a tty
Browse files Browse the repository at this point in the history
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
  • Loading branch information
krtyyy committed Mar 2, 2012
1 parent 8d46288 commit 4ef665a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions Authors
Expand Up @@ -27,6 +27,7 @@ Josh Kearney <josh@jk0.org>
Justin Santa Barbara <justin@fathomdb.com>
Justin Shepherd <jshepher@rackspace.com>
Ken Pepple <ken.pepple@gmail.com>
Ken Thomas <krt@yahoo-inc.com>
Kevin L. Mitchell <kevin.mitchell@rackspace.com>
Lorin Hochstein <lorin@isi.edu>
Major Hayden <major@mhtx.net>
Expand Down
4 changes: 4 additions & 0 deletions bin/glance
Expand Up @@ -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 == "":
Expand Down

0 comments on commit 4ef665a

Please sign in to comment.