<div><br></div><div>Pete,</div><div><br></div><div><div>There is clearly something interesting going on with scope. 'options', which appears to really be 'parser' get passed in as a variable, but are then gets over written before being used by the call using the global 'parser'.</div>
<div>(options, args) = parse_args(parser, args)</div></div><div><br></div><div>The history of the commands you run and the stacktrace from the errors/logs might help.</div><div><br></div><div>What were you expecting/trying to do with the code change?</div>
<div><br></div><div>Most of that code looks like it was written by Greg Holt and/or Chuck Thier.</div><div><br></div><div>Hopefully they can shed more light on this by eyeballing the code than I can.</div><div><br></div><div>
<br></div><br><br><div class="gmail_quote">On Thu, Apr 5, 2012 at 8:43 PM, Pete Zaitcev <span dir="ltr"><<a href="mailto:zaitcev@redhat.com">zaitcev@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi, All:<br>
<br>
In the process of tinkering for lp:959221, I made a benign modification<br>
to make it possible to invoke swift as a module, when everything broke<br>
loose with errors like "NameError: global name 'parser' is not defined".<br>
Looking at the code it seems like a thinko, with the following fix:<br>
<br>
diff --git a/bin/swift b/bin/swift<br>
index 0cac5d6..a14c646 100755<br>
--- a/bin/swift<br>
+++ b/bin/swift<br>
@@ -1202,7 +1203,7 @@ download --all OR download container [options] [object] [object] ...<br>
     stdout.'''.strip('\n')<br>
<br>
<br>
-def st_download(options, args, print_queue, error_queue):<br>
+def st_download(parser, args, print_queue, error_queue):<br>
     parser.add_option('-a', '--all', action='store_true', dest='yes_all',<br>
         default=False, help='Indicates that you really want to download '<br>
         'everything in the account')<br>
@@ -1378,7 +1379,7 @@ list [options] [container]<br>
 '''.strip('\n')<br>
<br>
<br>
-def st_list(options, args, print_queue, error_queue):<br>
+def st_list(parser, args, print_queue, error_queue):<br>
     parser.add_option('-p', '--prefix', dest='prefix', help='Will only list '<br>
         'items beginning with the prefix')<br>
     parser.add_option('-d', '--delimiter', dest='delimiter', help='Will roll '<br>
@@ -1423,7 +1424,7 @@ stat [container] [object]<br>
     args given (if any).'''.strip('\n')<br>
<br>
<br>
-def st_stat(options, args, print_queue, error_queue):<br>
+def st_stat(parser, args, print_queue, error_queue):<br>
     (options, args) = parse_args(parser, args)<br>
     args = args[1:]<br>
     conn = get_conn(options)<br>
@@ -1548,7 +1549,7 @@ post [options] [container] [object]<br>
     post -m Color:Blue -m Size:Large'''.strip('\n')<br>
<br>
<br>
-def st_post(options, args, print_queue, error_queue):<br>
+def st_post(parser, args, print_queue, error_queue):<br>
     parser.add_option('-r', '--read-acl', dest='read_acl', help='Sets the '<br>
         'Read ACL for containers. Quick summary of ACL syntax: .r:*, '<br>
         '.r:-.<a href="http://example.com" target="_blank">example.com</a>, .r:<a href="http://www.example.com" target="_blank">www.example.com</a>, account1, account2:user2')<br>
@@ -1619,7 +1620,7 @@ upload [options] container file_or_directory [file_or_directory] [...]<br>
 '''.strip('\n')<br>
<br>
<br>
-def st_upload(options, args, print_queue, error_queue):<br>
+def st_upload(parser, args, print_queue, error_queue):<br>
     parser.add_option('-c', '--changed', action='store_true', dest='changed',<br>
         default=False, help='Will only upload files that have changed since '<br>
         'the last upload')<br>
<br>
Seems obvious if I look at this:<br>
<br>
    globals()['st_%s' % args[0]](parser, argv[1:], print_queue, error_queue)<br>
<br>
The parser is always the first argument, so... Someone please tell me<br>
if I am missing something here. Or should I just file it in Gerrit?<br>
<br>
Weird part is, unit tests pass both on the current code and the one<br>
with my patch above. The problem seems too gross to let it work, but<br>
everything appears in order.<br>
<br>
-- Pete<br>
<br>
_______________________________________________<br>
Mailing list: <a href="https://launchpad.net/~openstack" target="_blank">https://launchpad.net/~openstack</a><br>
Post to     : <a href="mailto:openstack@lists.launchpad.net">openstack@lists.launchpad.net</a><br>
Unsubscribe : <a href="https://launchpad.net/~openstack" target="_blank">https://launchpad.net/~openstack</a><br>
More help   : <a href="https://help.launchpad.net/ListHelp" target="_blank">https://help.launchpad.net/ListHelp</a><br>
</blockquote></div><br>