diff options
| author | Jenkins <jenkins@review.openstack.org> | 2017-07-06 15:24:31 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2017-07-06 15:24:31 +0000 |
| commit | 91cc7311877c74adf2618bcb87f86f484e8d7aae (patch) | |
| tree | f7e28d40224762d4f531eaa13a7882e20d7cf44b /openstackclient/api/object_store_v1.py | |
| parent | eb19c167ead44a5df7a3ac072af8c4a0a895f36e (diff) | |
| parent | ae35a29169ab460cdd5d6b8c26d376c000a5c10e (diff) | |
| download | python-openstackclient-91cc7311877c74adf2618bcb87f86f484e8d7aae.tar.gz | |
Merge "Allow objects to be streamed to stdout"
Diffstat (limited to 'openstackclient/api/object_store_v1.py')
| -rw-r--r-- | openstackclient/api/object_store_v1.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/openstackclient/api/object_store_v1.py b/openstackclient/api/object_store_v1.py index 74c4a46f..31033525 100644 --- a/openstackclient/api/object_store_v1.py +++ b/openstackclient/api/object_store_v1.py @@ -16,6 +16,7 @@ import io import logging import os +import sys from osc_lib import utils import six @@ -376,12 +377,16 @@ class APIv1(api.BaseAPI): stream=True, ) if response.status_code == 200: - if not os.path.exists(os.path.dirname(file)): - if len(os.path.dirname(file)) > 0: - os.makedirs(os.path.dirname(file)) - with open(file, 'wb') as f: + if file == '-': for chunk in response.iter_content(64 * 1024): - f.write(chunk) + sys.stdout.write(chunk) + else: + if not os.path.exists(os.path.dirname(file)): + if len(os.path.dirname(file)) > 0: + os.makedirs(os.path.dirname(file)) + with open(file, 'wb') as f: + for chunk in response.iter_content(64 * 1024): + f.write(chunk) def object_set( self, |
