Allow objects to be streamed to stdout
Change-Id: Icd8de6b2122fe77926d93da9bda08f56c3672a7a
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user