Return error_code in command "job binary download"

return an error code if download file exists.

Change-Id: Ia7a21fb9f34ada1938eb169cc5ba2725d75874d7
This commit is contained in:
Shu Yingya 2016-09-27 16:03:43 +08:00
parent 7ede456acb
commit 214e2603de
1 changed files with 3 additions and 2 deletions

View File

@ -419,8 +419,9 @@ class DownloadJobBinary(command.Command):
data = client.job_binaries.get_file(jb_id)
if path.exists(parsed_args.file):
self.log.error('File "%s" already exists. Chose another one with '
'--file argument.' % parsed_args.file)
msg = ('File "%s" already exists. Chose another one with '
'--file argument.' % parsed_args.file)
raise exceptions.CommandError(msg)
else:
with open(parsed_args.file, 'w') as f:
f.write(data)