summaryrefslogtreecommitdiff
path: root/swiftclient/shell.py
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-12-15 19:02:23 +0000
committerGerrit Code Review <review@openstack.org>2014-12-15 19:02:23 +0000
commit7980704c33c478f73c353884f099550d6fcf853d (patch)
treeb9501bec38de4d75b786e8bd670ceb9e84a3c52a /swiftclient/shell.py
parent79fb53190e3087666d0357a5964645c0cba7fcf0 (diff)
parent5756fcc4f25b97692cba548863f3d2b27217ced1 (diff)
downloadpython-swiftclient-7980704c33c478f73c353884f099550d6fcf853d.tar.gz
Merge "Fix misnamed dictionary key."
Diffstat (limited to 'swiftclient/shell.py')
-rwxr-xr-xswiftclient/shell.py37
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)