Encode exception on ceilometer-client for UnicodeDecodeError

Current ceilometer client did not handle output exception which
is encoded, this patch implements the shell encoding for exception
output.

Change-Id: I3cddb277868e39765eccd68dc256f07e15a4207b
This commit is contained in:
ChenZheng
2013-11-21 16:22:14 +08:00
parent 2950b30089
commit 0259cd1079

View File

@@ -14,15 +14,20 @@
Command-line interface to the OpenStack Metering API.
"""
from __future__ import print_function
import argparse
import httplib2
import logging
import sys
import six
import ceilometerclient
from ceilometerclient import client as ceiloclient
from ceilometerclient.common import utils
from ceilometerclient import exc
from ceilometerclient.openstack.common import strutils
class CeilometerShell(object):
@@ -291,7 +296,7 @@ def main():
CeilometerShell().main(sys.argv[1:])
except Exception as e:
print >> sys.stderr, e
print(strutils.safe_encode(six.text_type(e)), file=sys.stderr)
sys.exit(1)
if __name__ == "__main__":