Ceilometer UnicodeEncodeError when update or show alarm fix
Fix display bug in ceilometer alarm-update ceilometer alarm-show when encounter a alarm with not unicode attributes. Change-Id: I0af0f1d6b8393c7117eb5b56fba3d5e1f4935ff1 Closes-bug: #1245317
This commit is contained in:
@@ -26,6 +26,7 @@ import prettytable
|
|||||||
from ceilometerclient import exc
|
from ceilometerclient import exc
|
||||||
from ceilometerclient.openstack.common import cliutils
|
from ceilometerclient.openstack.common import cliutils
|
||||||
from ceilometerclient.openstack.common import importutils
|
from ceilometerclient.openstack.common import importutils
|
||||||
|
from ceilometerclient.openstack.common import strutils
|
||||||
|
|
||||||
|
|
||||||
# Decorator for cli-args
|
# Decorator for cli-args
|
||||||
@@ -74,6 +75,8 @@ def print_dict(d, dict_property="Property", wrap=0):
|
|||||||
# convert dict to str to check length
|
# convert dict to str to check length
|
||||||
if isinstance(v, dict):
|
if isinstance(v, dict):
|
||||||
v = str(v)
|
v = str(v)
|
||||||
|
if isinstance(v, six.string_types):
|
||||||
|
v = strutils.safe_encode(v)
|
||||||
# if value has a newline, add in multiple rows
|
# if value has a newline, add in multiple rows
|
||||||
# e.g. fault with stacktrace
|
# e.g. fault with stacktrace
|
||||||
if v and isinstance(v, six.string_types) and r'\n' in v:
|
if v and isinstance(v, six.string_types) and r'\n' in v:
|
||||||
|
|||||||
Reference in New Issue
Block a user