switch to oslo.utils
oslo.utils is released and corresponding code in oslo-incubator has been removed. Change-Id: Ic3a13380809a8b00c979e5ac405b4084f486a31d
This commit is contained in:
@@ -19,13 +19,13 @@ import sys
|
||||
import textwrap
|
||||
import uuid
|
||||
|
||||
from oslo.utils import encodeutils
|
||||
from oslo.utils import importutils
|
||||
import prettytable
|
||||
import six
|
||||
|
||||
from ceilometerclient import exc
|
||||
from ceilometerclient.openstack.common import cliutils
|
||||
from ceilometerclient.openstack.common import importutils
|
||||
from ceilometerclient.openstack.common import strutils
|
||||
|
||||
|
||||
# Decorator for cli-args
|
||||
@@ -84,30 +84,29 @@ def format_nested_list_of_dict(l, column_names):
|
||||
|
||||
|
||||
def print_dict(d, dict_property="Property", wrap=0):
|
||||
pt = prettytable.PrettyTable([dict_property, 'Value'],
|
||||
caching=False, print_empty=False)
|
||||
pt = prettytable.PrettyTable([dict_property, 'Value'], print_empty=False)
|
||||
pt.align = 'l'
|
||||
for k, v in sorted(six.iteritems(d)):
|
||||
for k, v in six.iteritems(d):
|
||||
# convert dict to str to check length
|
||||
if isinstance(v, dict):
|
||||
v = str(v)
|
||||
if isinstance(v, six.string_types):
|
||||
v = strutils.safe_encode(v)
|
||||
if wrap > 0:
|
||||
v = textwrap.fill(str(v), wrap)
|
||||
# if value has a newline, add in multiple rows
|
||||
# e.g. fault with stacktrace
|
||||
if v and isinstance(v, six.string_types) and r'\n' in v:
|
||||
lines = v.strip().split(r'\n')
|
||||
col1 = k
|
||||
for line in lines:
|
||||
if wrap > 0:
|
||||
line = textwrap.fill(str(line), wrap)
|
||||
pt.add_row([col1, line])
|
||||
col1 = ''
|
||||
else:
|
||||
if wrap > 0:
|
||||
v = textwrap.fill(str(v), wrap)
|
||||
pt.add_row([k, v])
|
||||
print(pt.get_string())
|
||||
encoded = encodeutils.safe_encode(pt.get_string(sortby=dict_property))
|
||||
# FIXME(gordc): https://bugs.launchpad.net/oslo-incubator/+bug/1370710
|
||||
if six.PY3:
|
||||
encoded = encoded.decode()
|
||||
print(encoded)
|
||||
|
||||
|
||||
def find_resource(manager, name_or_id):
|
||||
|
||||
@@ -20,6 +20,7 @@ import argparse
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from oslo.utils import encodeutils
|
||||
import six
|
||||
|
||||
import ceilometerclient
|
||||
@@ -27,7 +28,6 @@ from ceilometerclient import client as ceiloclient
|
||||
from ceilometerclient.common import utils
|
||||
from ceilometerclient import exc
|
||||
from ceilometerclient.openstack.common import cliutils
|
||||
from ceilometerclient.openstack.common import strutils
|
||||
|
||||
|
||||
class CeilometerShell(object):
|
||||
@@ -278,7 +278,7 @@ def main(args=None):
|
||||
if '--debug' in args or '-d' in args:
|
||||
raise
|
||||
else:
|
||||
print(strutils.safe_encode(six.text_type(e)), file=sys.stderr)
|
||||
print(encodeutils.safe_encode(six.text_type(e)), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -22,11 +22,11 @@ import argparse
|
||||
import functools
|
||||
import json
|
||||
|
||||
from oslo.utils import strutils
|
||||
import six
|
||||
|
||||
from ceilometerclient.common import utils
|
||||
from ceilometerclient import exc
|
||||
from ceilometerclient.openstack.common import strutils
|
||||
from ceilometerclient.v2 import options
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
# The list of modules to copy from openstack-common
|
||||
module=cliutils
|
||||
module=importutils
|
||||
module=install_venv_common
|
||||
|
||||
# The base module to hold the copy of openstack.common
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
pbr>=0.6,!=0.7,<1.0
|
||||
argparse
|
||||
iso8601>=0.1.9
|
||||
oslo.utils>=1.0.0 # Apache-2.0
|
||||
PrettyTable>=0.7,<0.8
|
||||
python-keystoneclient>=0.10.0
|
||||
six>=1.7.0
|
||||
|
||||
Reference in New Issue
Block a user