diff options
author | Andrey Kurilin <akurilin@mirantis.com> | 2014-08-27 18:08:14 +0300 |
---|---|---|
committer | Andrey Kurilin <akurilin@mirantis.com> | 2014-08-28 12:17:22 +0300 |
commit | 392148c7ef6d05cb5fd05d8287af460a6651ee4d (patch) | |
tree | 757db639d81f45b5dfb98d947f6559b72f920f37 /novaclient/utils.py | |
parent | aa30c13fc5f8fd6288a6f1c39b0bbb98bd441456 (diff) | |
download | python-novaclient-392148c7ef6d05cb5fd05d8287af460a6651ee4d.tar.gz |
Use oslo.utils
Modules `strutils`, `timeutils` and `network_utils` from common code are
graduated in `oslo.utils`, so we can:
1. remove `novaclient.openstack.common.network_utils` and use
`oslo.utils.netutils` instead.
2. use `oslo.utils.encodeutils` and `oslo.utils.strutils` instead of
`novaclient.openstack.common.strutils`.
3. use `oslo.utils.timeutils` instead of
`novaclient.openstack.common.timeutils`.
Additional information:
- modules `importutils`, `strutils` and `timeutils` from
`novaclient.openstack.common` cannot be removed, because:
- importutils is used by apiclient and jsonutils;
- strutils is used by apiclient, cliutils and jsonutils;
- timeutils is used by jsonutils
- additional check for `safe_encode` in Py3 is required, since
If91a866d864a22d28a352152beff4c7406a27b7b was merged.
Change-Id: Ib8d79d9c85af4916e87a76a1a67a13488ddaa111
Diffstat (limited to 'novaclient/utils.py')
-rw-r--r-- | novaclient/utils.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/novaclient/utils.py b/novaclient/utils.py index 8600cab0..d6068ba0 100644 --- a/novaclient/utils.py +++ b/novaclient/utils.py @@ -17,6 +17,7 @@ import sys import textwrap import uuid +from oslo.utils import encodeutils import pkg_resources import prettytable import six @@ -25,7 +26,6 @@ from novaclient import exceptions from novaclient.openstack.common import cliutils from novaclient.openstack.common.gettextutils import _ from novaclient.openstack.common import jsonutils -from novaclient.openstack.common import strutils arg = cliutils.arg @@ -127,9 +127,12 @@ def print_list(objs, fields, formatters={}, sortby_index=None): pt.add_row(row) if sortby is not None: - result = strutils.safe_encode(pt.get_string(sortby=sortby)) + result = encodeutils.safe_encode(pt.get_string(sortby=sortby)) else: - result = strutils.safe_encode(pt.get_string()) + result = encodeutils.safe_encode(pt.get_string()) + + if six.PY3: + result = result.decode() print(result) @@ -197,7 +200,10 @@ def print_dict(d, dict_property="Property", dict_value="Value", wrap=0): v = '-' pt.add_row([k, v]) - result = strutils.safe_encode(pt.get_string()) + result = encodeutils.safe_encode(pt.get_string()) + + if six.PY3: + result = result.decode() print(result) @@ -219,7 +225,11 @@ def find_resource(manager, name_or_id, **find_args): # now try to get entity as uuid try: - tmp_id = strutils.safe_encode(name_or_id) + tmp_id = encodeutils.safe_encode(name_or_id) + + if six.PY3: + tmp_id = tmp_id.decode() + uuid.UUID(tmp_id) return manager.get(tmp_id) except (TypeError, ValueError, exceptions.NotFound): |