~corey.bryant/python-novaclient/2.26.0

« back to all changes in this revision

Viewing changes to novaclient/utils.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2014-09-18 08:52:31 UTC
  • mfrom: (1.1.35)
  • Revision ID: package-import@ubuntu.com-20140918085231-56hs515gp9zpb9sd
Tags: 1:2.19.0-0ubuntu1
* New upstream release.
* debian/control: Drop python-d2to1, python-httpretty as build dependency.
* debian/control: Add python-requests-mock as build dependency.
* debian/control: Add python-oslo.utils.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#    under the License.
13
13
 
14
14
import json
15
 
import pkg_resources
16
15
import re
17
16
import sys
18
17
import textwrap
19
18
import uuid
20
19
 
 
20
from oslo.utils import encodeutils
 
21
import pkg_resources
21
22
import prettytable
22
23
import six
23
24
 
25
26
from novaclient.openstack.common import cliutils
26
27
from novaclient.openstack.common.gettextutils import _
27
28
from novaclient.openstack.common import jsonutils
28
 
from novaclient.openstack.common import strutils
29
29
 
30
30
 
31
31
arg = cliutils.arg
127
127
        pt.add_row(row)
128
128
 
129
129
    if sortby is not None:
130
 
        result = strutils.safe_encode(pt.get_string(sortby=sortby))
 
130
        result = encodeutils.safe_encode(pt.get_string(sortby=sortby))
131
131
    else:
132
 
        result = strutils.safe_encode(pt.get_string())
 
132
        result = encodeutils.safe_encode(pt.get_string())
 
133
 
 
134
    if six.PY3:
 
135
        result = result.decode()
133
136
 
134
137
    print(result)
135
138
 
197
200
                v = '-'
198
201
            pt.add_row([k, v])
199
202
 
200
 
    result = strutils.safe_encode(pt.get_string())
 
203
    result = encodeutils.safe_encode(pt.get_string())
 
204
 
 
205
    if six.PY3:
 
206
        result = result.decode()
201
207
 
202
208
    print(result)
203
209
 
219
225
 
220
226
    # now try to get entity as uuid
221
227
    try:
222
 
        tmp_id = strutils.safe_encode(name_or_id)
 
228
        tmp_id = encodeutils.safe_encode(name_or_id)
 
229
 
 
230
        if six.PY3:
 
231
            tmp_id = tmp_id.decode()
 
232
 
223
233
        uuid.UUID(tmp_id)
224
234
        return manager.get(tmp_id)
225
235
    except (TypeError, ValueError, exceptions.NotFound):