diff options
author | Louis Taylor <kragniz@gmail.com> | 2015-01-06 14:32:05 +0000 |
---|---|---|
committer | Louis Taylor <kragniz@gmail.com> | 2015-01-27 19:22:42 +0000 |
commit | b818826420a383e733ec40881ff436595ca57cc8 (patch) | |
tree | 12222b8c40f9cbdf22ecff0e2a99739cef18576e /glanceclient/common/utils.py | |
parent | 363b17085195e6f38c8b7cf3ac3398f5f3806305 (diff) | |
download | python-glanceclient-b818826420a383e733ec40881ff436595ca57cc8.tar.gz |
Remove openstack.common.strutils
This module now lives in oslo.utils, so import it from there instead.
Co-Authored-By: Ian Cordasco <ian.cordasco@rackspace.com>
Change-Id: Ib35dc840992433542490670781badd9529ec8947
Diffstat (limited to 'glanceclient/common/utils.py')
-rw-r--r-- | glanceclient/common/utils.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/glanceclient/common/utils.py b/glanceclient/common/utils.py index 61c526e..d99d4ae 100644 --- a/glanceclient/common/utils.py +++ b/glanceclient/common/utils.py @@ -31,11 +31,12 @@ if os.name == 'nt': else: msvcrt = None +from oslo.utils import encodeutils +from oslo.utils import strutils import prettytable from glanceclient import exc from glanceclient.openstack.common import importutils -from glanceclient.openstack.common import strutils _memoized_property_lock = threading.Lock() @@ -150,7 +151,7 @@ def print_list(objs, fields, formatters=None, field_settings=None): row.append(data) pt.add_row(row) - print(strutils.safe_encode(pt.get_string())) + print(encodeutils.safe_decode(pt.get_string())) def print_dict(d, max_column_width=80): @@ -161,7 +162,7 @@ def print_dict(d, max_column_width=80): if isinstance(v, (dict, list)): v = json.dumps(v) pt.add_row([k, v]) - print(strutils.safe_encode(pt.get_string(sortby='Property'))) + print(encodeutils.safe_decode(pt.get_string(sortby='Property'))) def find_resource(manager, name_or_id): @@ -175,7 +176,9 @@ def find_resource(manager, name_or_id): # now try to get entity as uuid try: - uuid.UUID(strutils.safe_encode(name_or_id)) + # This must be unicode for Python 3 compatibility. + # If you pass a bytestring to uuid.UUID, you will get a TypeError + uuid.UUID(encodeutils.safe_decode(name_or_id)) return manager.get(name_or_id) except (ValueError, exc.NotFound): pass @@ -233,7 +236,7 @@ def import_versioned_module(version, submodule=None): def exit(msg=''): if msg: - print(strutils.safe_encode(msg), file=sys.stderr) + print(encodeutils.safe_decode(msg), file=sys.stderr) sys.exit(1) @@ -291,7 +294,7 @@ def exception_to_str(exc): except UnicodeError: error = ("Caught '%(exception)s' exception." % {"exception": exc.__class__.__name__}) - return strutils.safe_encode(error, errors='ignore') + return encodeutils.safe_decode(error, errors='ignore') def get_file_size(file_obj): |