print usage when no argument is specified for python3

When running just 'glance' under python3, we will get the error:
ERROR: 'Namespace' object has no attribute 'func'

This is because map() is used to decode sys.argv, but under Python3
it returns a map object which is an iterable. Some code later tries
to use this in a boolean context and it will always return True,
even if it's empty.

Change-Id: I2f03e462cb813833b75b9f2de7badd10b10cddff
Closes-Bug: #1295356
This commit is contained in:
Zhiqiang Fan
2015-09-27 09:38:04 -06:00
parent c567edc2b2
commit a8a7c68990
2 changed files with 16 additions and 1 deletions
+2 -1
View File
@@ -759,7 +759,8 @@ class HelpFormatter(argparse.HelpFormatter):
def main():
try:
OpenStackImagesShell().main(map(encodeutils.safe_decode, sys.argv[1:]))
argv = [encodeutils.safe_decode(a) for a in sys.argv[1:]]
OpenStackImagesShell().main(argv)
except KeyboardInterrupt:
utils.exit('... terminating glance client', exit_code=130)
except Exception as e: