From 3aabe86e344629527de0a04c9215e0bd34a0b4a8 Mon Sep 17 00:00:00 2001 From: Pete Zaitcev Date: Tue, 10 Apr 2012 10:27:54 -0600 Subject: [PATCH] Make swift client easier to wrap In the process of wrapping for profiling, a trivial wrap with def main() ended in a ton of these: NameError: global name 'parser' is not defined A closer investigation revealed an apparent confusion in argument names. The problem was introduced by commit 985968f76550251904b64d12de025fa5d65ed03f of November 2010. Note that Greg fixed st_delete() correctly in that one, but apparently forgot the others. Unit tests pass for both current (bad) code, and the patched code. By the magic of Python scoping, current code works, just impossible to wrap for a quick hack. Change-Id: I18f2494ce2a201d04d49f99ea259d141939dcb6a --- bin/swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/swift b/bin/swift index 37e0da0411..4b5c74c674 100755 --- a/bin/swift +++ b/bin/swift @@ -1208,7 +1208,7 @@ download --all OR download container [options] [object] [object] ... stdout.'''.strip('\n') -def st_download(options, args, print_queue, error_queue): +def st_download(parser, args, print_queue, error_queue): parser.add_option('-a', '--all', action='store_true', dest='yes_all', default=False, help='Indicates that you really want to download ' 'everything in the account') @@ -1384,7 +1384,7 @@ list [options] [container] '''.strip('\n') -def st_list(options, args, print_queue, error_queue): +def st_list(parser, args, print_queue, error_queue): parser.add_option('-p', '--prefix', dest='prefix', help='Will only list ' 'items beginning with the prefix') parser.add_option('-d', '--delimiter', dest='delimiter', help='Will roll ' @@ -1429,7 +1429,7 @@ stat [container] [object] args given (if any).'''.strip('\n') -def st_stat(options, args, print_queue, error_queue): +def st_stat(parser, args, print_queue, error_queue): (options, args) = parse_args(parser, args) args = args[1:] conn = get_conn(options) @@ -1554,7 +1554,7 @@ post [options] [container] [object] post -m Color:Blue -m Size:Large'''.strip('\n') -def st_post(options, args, print_queue, error_queue): +def st_post(parser, args, print_queue, error_queue): parser.add_option('-r', '--read-acl', dest='read_acl', help='Sets the ' 'Read ACL for containers. Quick summary of ACL syntax: .r:*, ' '.r:-.example.com, .r:www.example.com, account1, account2:user2') @@ -1625,7 +1625,7 @@ upload [options] container file_or_directory [file_or_directory] [...] '''.strip('\n') -def st_upload(options, args, print_queue, error_queue): +def st_upload(parser, args, print_queue, error_queue): parser.add_option('-c', '--changed', action='store_true', dest='changed', default=False, help='Will only upload files that have changed since ' 'the last upload')