summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-10-31 16:46:31 +0000
committerGerrit Code Review <review@openstack.org>2016-10-31 16:46:31 +0000
commit08fc1bdccc3b4b64384891bbe70a7637935314e1 (patch)
tree5b24bbe47a1572cd1964fcf6d834c8d44f3b4825
parentdeb1e31016ca0c52aef34017d12843d9b754bb53 (diff)
parent266a7efbad9bf733de19b92174baf8768fc03d4b (diff)
downloadpython-saharaclient-08fc1bdccc3b4b64384891bbe70a7637935314e1.tar.gz
Merge "Optimize command job-binary-download"
-rw-r--r--saharaclient/osc/v1/job_binaries.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/saharaclient/osc/v1/job_binaries.py b/saharaclient/osc/v1/job_binaries.py
index e828084..30ad2e9 100644
--- a/saharaclient/osc/v1/job_binaries.py
+++ b/saharaclient/osc/v1/job_binaries.py
@@ -414,15 +414,15 @@ class DownloadJobBinary(command.Command):
if not parsed_args.file:
parsed_args.file = parsed_args.job_binary
- jb_id = utils.get_resource_id(
- client.job_binaries, parsed_args.job_binary)
- data = client.job_binaries.get_file(jb_id)
-
if path.exists(parsed_args.file):
msg = ('File "%s" already exists. Chose another one with '
'--file argument.' % parsed_args.file)
raise exceptions.CommandError(msg)
else:
+ jb_id = utils.get_resource_id(
+ client.job_binaries, parsed_args.job_binary)
+ data = client.job_binaries.get_file(jb_id)
+
with open(parsed_args.file, 'w') as f:
f.write(data)
sys.stdout.write(