diff options
author | Zuul <zuul@review.opendev.org> | 2022-07-07 16:09:21 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2022-07-07 16:09:21 +0000 |
commit | 541593e57ea57f05b3add4c5b84bf8f649e12271 (patch) | |
tree | 0c3a77e2872ce268ae33afd35808b770adf224a2 | |
parent | 507f16ee161e14cd00133c6d064f39082197494b (diff) | |
parent | 8df9328a60045edae36dc64cee1f2cf3cd4a09fa (diff) | |
download | python-glanceclient-541593e57ea57f05b3add4c5b84bf8f649e12271.tar.gz |
Merge "Check if stdin has isatty attribute"
-rw-r--r-- | glanceclient/common/utils.py | 2 | ||||
-rw-r--r-- | glanceclient/v2/shell.py | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/glanceclient/common/utils.py b/glanceclient/common/utils.py index fd0243c..c3f08de 100644 --- a/glanceclient/common/utils.py +++ b/glanceclient/common/utils.py @@ -447,7 +447,7 @@ def get_data_file(args): except OSError: # (1) stdin is not valid (closed...) return None - if not sys.stdin.isatty(): + if hasattr(sys.stdin, 'isatty') and not sys.stdin.isatty(): # (2) image data is provided through standard input image = sys.stdin if hasattr(sys.stdin, 'buffer'): diff --git a/glanceclient/v2/shell.py b/glanceclient/v2/shell.py index be627f5..84e3639 100644 --- a/glanceclient/v2/shell.py +++ b/glanceclient/v2/shell.py @@ -94,7 +94,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.") @@ -205,7 +205,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): |