summaryrefslogtreecommitdiff
path: root/swiftclient/shell.py
diff options
context:
space:
mode:
Diffstat (limited to 'swiftclient/shell.py')
-rwxr-xr-xswiftclient/shell.py51
1 files changed, 23 insertions, 28 deletions
diff --git a/swiftclient/shell.py b/swiftclient/shell.py
index 015c9d9..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)
@@ -547,8 +542,7 @@ If the container is not found, it will be created automatically.
Positional arguments:
[container] Name of container to post to.
- [object] Name of object to post. Specify multiple times
- for multiple objects.
+ [object] Name of object to post.
Optional arguments:
--read-acl <acl> Read ACL for containers. Quick summary of ACL syntax:
@@ -600,7 +594,7 @@ def st_post(parser, args, output_manager):
with SwiftService(options=_opts) as swift:
try:
if not args:
- swift.post()
+ result = swift.post()
else:
container = args[0]
if '/' in container:
@@ -616,15 +610,16 @@ def st_post(parser, args, output_manager):
results_iterator = swift.post(
container=container, objects=objects
)
- for result in results_iterator: # only 1 result
- if not result["success"]:
- raise(result["error"])
+ result = next(results_iterator)
else:
output_manager.error(
'Usage: %s post %s\n%s', BASENAME,
st_post_options, st_post_help)
+ return
else:
- swift.post(container=container)
+ result = swift.post(container=container)
+ if not result["success"]:
+ raise(result["error"])
except SwiftError as e:
output_manager.error(e.value)