diff options
author | Daniel Wakefield <daniel.wakefield@hp.com> | 2014-10-20 11:55:12 +0100 |
---|---|---|
committer | Daniel Wakefield <daniel.wakefield@hp.com> | 2014-12-08 15:45:40 +0000 |
commit | 5756fcc4f25b97692cba548863f3d2b27217ced1 (patch) | |
tree | 55cbaf9bf19caf5043416301d90ab109c14201cb /swiftclient/shell.py | |
parent | d89e08f722f030925495a4180d2fe8422977841d (diff) | |
download | python-swiftclient-5756fcc4f25b97692cba548863f3d2b27217ced1.tar.gz |
Fix misnamed dictionary key.
The response dictionary in _delete_segment attach's any error
it encounters to the dict key 'exception', all other response
dict's use 'error' to store the exception.
Changed to make it consistent and added tests
Also added a third branch in st_delete as messages
created in _delete_container where being silently dropped.
Change-Id: Ifbc3b1fae78910fbc6acf4a86cfb0f60bb1aa336
Diffstat (limited to 'swiftclient/shell.py')
-rwxr-xr-x | swiftclient/shell.py | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/swiftclient/shell.py b/swiftclient/shell.py index 2c627ad..8d4da67 100755 --- a/swiftclient/shell.py +++ b/swiftclient/shell.py @@ -118,34 +118,29 @@ def st_delete(parser, args, output_manager): del_iter = swift.delete(container=container) for r in del_iter: + c = r.get('container', '') + o = r.get('object', '') + a = r.get('attempts') + if r['success']: if options.verbose: + a = ' [after {0} attempts]'.format(a) if a > 1 else '' + if r['action'] == 'delete_object': - c = r['container'] - o = r['object'] - p = '%s/%s' % (c, o) if options.yes_all else o - a = r['attempts'] - if a > 1: - output_manager.print_msg( - '%s [after %d attempts]', p, a) + if options.yes_all: + p = '{0}/{1}'.format(c, o) else: - output_manager.print_msg(p) - + p = o elif r['action'] == 'delete_segment': - c = r['container'] - o = r['object'] - p = '%s/%s' % (c, o) - a = r['attempts'] - if a > 1: - output_manager.print_msg( - '%s [after %d attempts]', p, a) - else: - output_manager.print_msg(p) + p = '{0}/{1}'.format(c, o) + elif r['action'] == 'delete_container': + p = c + output_manager.print_msg('{0}{1}'.format(p, a)) else: - # Special case error prints - output_manager.error("An unexpected error occurred whilst " - "deleting: %s" % r['error']) + p = '{0}/{1}'.format(c, o) if o else c + output_manager.error('Error Deleting: {0}: {1}' + .format(p, r['error'])) except SwiftError as err: output_manager.error(err.value) |