summaryrefslogtreecommitdiff
path: root/glanceclient/v2/shell.py
diff options
context:
space:
mode:
authorBenedikt Loeffler <benedikt.loeffler@bmw.de>2021-10-13 13:50:36 +0200
committerCyril Roelandt <cyril@redhat.com>2022-07-08 04:38:59 +0200
commitf0ccd09ad5976cc67eaca244c820a7106aecf4c5 (patch)
treefb2f92f63e8f569e864113e662bf1e82e3d6d800 /glanceclient/v2/shell.py
parent0b4d5a6200f638fc299d4cffa1c2f4367a6c6e80 (diff)
downloadpython-glanceclient-stable/xena.tar.gz
Check if stdin has isatty attributestable/xena
When the stdin is closed, it has no isatty atrribute which leads to a KeyError. Closes-Bug: #1980890 Change-Id: If9a3bf68b8dfd953b346697241166578d18bb563 (cherry picked from commit 8df9328a60045edae36dc64cee1f2cf3cd4a09fa) (cherry picked from commit 2ad5f0a6b07c25cc8bc371a92baea3d1c52161ad)
Diffstat (limited to 'glanceclient/v2/shell.py')
-rw-r--r--glanceclient/v2/shell.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/glanceclient/v2/shell.py b/glanceclient/v2/shell.py
index 5f83bd2..46bc380 100644
--- a/glanceclient/v2/shell.py
+++ b/glanceclient/v2/shell.py
@@ -93,7 +93,7 @@ def do_image_create(gc, args):
backend = args.store
file_name = fields.pop('file', None)
- using_stdin = not sys.stdin.isatty()
+ using_stdin = hasattr(sys.stdin, 'isatty') and not sys.stdin.isatty()
if args.store and not (file_name or using_stdin):
utils.exit("--store option should only be provided with --file "
"option or stdin.")
@@ -204,7 +204,7 @@ def do_image_create_via_import(gc, args):
fields[key] = value
file_name = fields.pop('file', None)
- using_stdin = not sys.stdin.isatty()
+ using_stdin = hasattr(sys.stdin, 'isatty') and not sys.stdin.isatty()
# special processing for backward compatibility with image-create
if args.import_method is None and (file_name or using_stdin):