Merge "Added support for unicode in client in fuelclient"

This commit is contained in:
Jenkins
2014-06-05 11:38:02 +00:00
committed by Gerrit Code Review
5 changed files with 29 additions and 13 deletions

View File

@@ -88,10 +88,11 @@ class EnvironmentAction(Action):
data = env.set(mode=params.mode)
else:
data = env.get_fresh_data()
self.serializer.print_to_output(
data,
"Environment '{name}' with id={id}, mode={mode}"
" and network-mode={net_provider} was created!"
u"Environment '{name}' with id={id}, mode={mode}"
u" and network-mode={net_provider} was created!"
.format(**data)
)

View File

@@ -54,18 +54,20 @@ def format_table(data, acceptable_keys=None, column_to_join=None):
)
for row in rows:
column_widths.update(
(index, max(column_widths[index], len(str(element))))
(index, max(column_widths[index], len(unicode(element))))
for index, element in enumerate(row)
)
row_template = ' | '.join(
"{{{0}:{1}}}".format(idx, width)
row_template = u' | '.join(
u"{{{0}:{1}}}".format(idx, width)
for idx, width in column_widths.iteritems()
)
return '\n'.join(
return u'\n'.join(
(row_template.format(*header),
'-|-'.join(column_widths[column_index] * '-'
for column_index in range(number_of_columns)),
'\n'.join(row_template.format(*map(str, x)) for x in rows))
u'-|-'.join(column_widths[column_index] * u'-'
for column_index in range(number_of_columns)),
u'\n'.join(row_template.format(*map(unicode, x))
for x in rows))
)
@@ -243,8 +245,8 @@ def print_health_check(env):
)
for test in new_finished_tests:
print(
"[{0:2} of {1}] [{status}] '{name}' "
"({taken:.4} s) {message}".format(
u"[{0:2} of {1}] [{status}] '{name}' "
u"({taken:.4} s) {message}".format(
test_counter,
total_tests_count,
**test

View File

@@ -63,7 +63,7 @@ class Serializer(object):
if self.format_flags:
self.print_formatted(formatted_data)
else:
print_method(arg)
print_method(arg.encode('utf-8'))
def prepare_path(self, path):
return "{0}.{1}".format(

View File

@@ -247,7 +247,7 @@ class Environment(BaseObject):
(serializer or self.serializer).write_to_file(
engine_file_path, facts["engine"])
facts = facts["nodes"]
name_template = "{name}"
name_template = u"{name}"
else:
name_template = "{role}_{uid}"
for _fact in facts:

View File

@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
#
# Copyright 2013-2014 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -127,6 +129,17 @@ class TestHandlers(BaseTestCase):
)
class TestCharset(BaseTestCase):
def test_charset_problem(self):
self.load_data_to_nailgun_server()
self.run_cli_commands((
"env create --name=привет --release=1",
"--env-id=1 node set --node 1 --role=controller",
"env"
))
class TestFiles(BaseTestCase):
def setUp(self):