From 025da14326d29051119fff50424748e41bf4be42 Mon Sep 17 00:00:00 2001 From: Daniel Wakefield Date: Mon, 20 Oct 2014 18:00:01 +0100 Subject: 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 --- swiftclient/shell.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'swiftclient/shell.py') 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 ] [--write-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: -- cgit v1.2.1