diff options
author | Daniel Wakefield <daniel.wakefield@hp.com> | 2014-10-20 18:00:01 +0100 |
---|---|---|
committer | Alistair Coles <alistair.coles@hp.com> | 2014-10-21 08:23:26 +0000 |
commit | 025da14326d29051119fff50424748e41bf4be42 (patch) | |
tree | 8de2977739d6009ba1597396ae0c22fd8ab661e2 /swiftclient/shell.py | |
parent | 43c1141baa6c5a5987fd4ab71d1c2299898ea251 (diff) | |
download | python-swiftclient-025da14326d29051119fff50424748e41bf4be42.tar.gz |
Replaces Stacktraces with useful error messages.
Changed the message shown when a user doesn't enter project/tenant
id/name to be more informative.
When attempting to stat a container without supplying project/tenant
name or id, an empty response was being returned instead of an error
being raised.
Changed the error raised in swiftclient.client when no tenant or project
is specified to be more specific.
Add tests for basic regression checking.
Closes-Bug: #1372589
Change-Id: I4eb6964d9f1702db119cc0294edc02841b1ecd5f
Diffstat (limited to 'swiftclient/shell.py')
-rwxr-xr-x | swiftclient/shell.py | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/swiftclient/shell.py b/swiftclient/shell.py index 619ec5c..015c9d9 100755 --- a/swiftclient/shell.py +++ b/swiftclient/shell.py @@ -488,13 +488,15 @@ def st_stat(parser, args, output_manager): _opts = vars(options) with SwiftService(options=_opts) as swift: - if not args: - stat_result = swift.stat() - items = stat_result['items'] - headers = stat_result['headers'] - print_account_stats(items, headers, output_manager) - else: - try: + try: + if not args: + stat_result = swift.stat() + if not stat_result['success']: + raise stat_result['error'] + items = stat_result['items'] + headers = stat_result['headers'] + print_account_stats(items, headers, output_manager) + else: container = args[0] if '/' in container: output_manager.error( @@ -505,6 +507,8 @@ def st_stat(parser, args, output_manager): args = args[1:] if not args: stat_result = swift.stat(container=container) + if not stat_result['success']: + raise stat_result['error'] items = stat_result['items'] headers = stat_result['headers'] print_container_stats(items, headers, output_manager) @@ -527,8 +531,8 @@ def st_stat(parser, args, output_manager): 'Usage: %s stat %s\n%s', BASENAME, st_stat_options, st_stat_help) - except SwiftError as e: - output_manager.error(e.value) + except SwiftError as e: + output_manager.error(e.value) st_post_options = '''[--read-acl <acl>] [--write-acl <acl>] [--sync-to] @@ -961,8 +965,8 @@ def parse_args(parser, args, enforce_requires=True): if (not (options.auth and options.user and options.key) and options.auth_version != '3'): - # Use keystone auth if any of the old-style args are missing - options.auth_version = '2.0' + # Use keystone auth if any of the old-style args are missing + options.auth_version = '2.0' # Use new-style args if old ones not present if not options.auth and options.os_auth_url: |