diff options
Diffstat (limited to 'openstackclient')
| -rw-r--r-- | openstackclient/shell.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/openstackclient/shell.py b/openstackclient/shell.py index 53e9be08..d4980a95 100644 --- a/openstackclient/shell.py +++ b/openstackclient/shell.py @@ -17,7 +17,9 @@ """Command-line interface to the OpenStack APIs""" import getpass +import locale import logging +import six import sys import traceback @@ -437,8 +439,17 @@ class OpenStackShell(app.App): tcmd.run(targs) -def main(argv=sys.argv[1:]): +def main(argv=None): + if argv is None: + argv = sys.argv[1:] + if six.PY2: + # Emulate Py3, decode argv into Unicode based on locale so that + # commands always see arguments as text instead of binary data + encoding = locale.getpreferredencoding() + if encoding: + argv = map(lambda arg: arg.decode(encoding), argv) + return OpenStackShell().run(argv) if __name__ == "__main__": - sys.exit(main(sys.argv[1:])) + sys.exit(main()) |
