diff options
Diffstat (limited to 'glanceclient/common')
-rw-r--r-- | glanceclient/common/http.py | 2 | ||||
-rw-r--r-- | glanceclient/common/utils.py | 7 |
2 files changed, 6 insertions, 3 deletions
diff --git a/glanceclient/common/http.py b/glanceclient/common/http.py index 0eb42de..7556537 100644 --- a/glanceclient/common/http.py +++ b/glanceclient/common/http.py @@ -63,7 +63,7 @@ class _BaseHTTPClient(object): chunk = body while chunk: chunk = body.read(CHUNKSIZE) - if chunk == '': + if not chunk: break yield chunk diff --git a/glanceclient/common/utils.py b/glanceclient/common/utils.py index 2bdca0a..9f3a1fe 100644 --- a/glanceclient/common/utils.py +++ b/glanceclient/common/utils.py @@ -360,9 +360,12 @@ def get_data_file(args): return None if not sys.stdin.isatty(): # (2) image data is provided through standard input + image = sys.stdin + if hasattr(sys.stdin, 'buffer'): + image = sys.stdin.buffer if msvcrt: - msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) - return sys.stdin + msvcrt.setmode(image.fileno(), os.O_BINARY) + return image else: # (3) no image data provided return None |