* Use six to handle unicode conversion
This commit is contained in:
committed by
tamarrow
parent
e88bffe306
commit
ea619b359a
@@ -2,6 +2,8 @@ import functools
|
||||
import sys
|
||||
import time
|
||||
|
||||
import six
|
||||
|
||||
from dcos import emitting, util
|
||||
from dcos.errors import DCOSException
|
||||
|
||||
@@ -89,7 +91,7 @@ def _stream_files(curr_header, fn, mesos_files):
|
||||
if lines:
|
||||
curr_header = _output(curr_header,
|
||||
len(reachable_files) > 1,
|
||||
str(mesos_file),
|
||||
six.text_type(mesos_file),
|
||||
lines)
|
||||
|
||||
return curr_header, reachable_files
|
||||
|
||||
@@ -4,6 +4,7 @@ import sys
|
||||
|
||||
import dcoscli
|
||||
import docopt
|
||||
import six
|
||||
from dcos import constants, emitting, errors, http, subcommand, util
|
||||
from dcos.errors import DCOSException
|
||||
from dcoscli.subcommand import SubcommandMain, default_doc
|
||||
@@ -127,7 +128,7 @@ def set_ssl_info_env_vars(config):
|
||||
if 'core.ssl_verify' in config and (
|
||||
not os.environ.get(constants.DCOS_SSL_VERIFY_ENV)):
|
||||
|
||||
os.environ[constants.DCOS_SSL_VERIFY_ENV] = str(
|
||||
os.environ[constants.DCOS_SSL_VERIFY_ENV] = six.text_type(
|
||||
config['core.ssl_verify'])
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -6,6 +6,7 @@ import time
|
||||
import dcoscli
|
||||
import docopt
|
||||
import pkg_resources
|
||||
import six
|
||||
from dcos import cmds, emitting, http, jsonitem, marathon, options, util
|
||||
from dcos.errors import DCOSException
|
||||
from dcoscli import tables
|
||||
@@ -297,7 +298,7 @@ def _list(json_):
|
||||
else:
|
||||
deployments = client.get_deployments()
|
||||
table = tables.app_table(apps, deployments)
|
||||
output = str(table)
|
||||
output = six.text_type(table)
|
||||
if output:
|
||||
emitter.publish(output)
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import subprocess
|
||||
|
||||
import dcoscli
|
||||
import docopt
|
||||
import six
|
||||
from dcos import cmds, emitting, errors, mesos, util
|
||||
from dcos.errors import DCOSException, DefaultError
|
||||
from dcoscli import log, tables
|
||||
@@ -97,7 +98,7 @@ def _list(json_):
|
||||
emitter.publish(slaves)
|
||||
else:
|
||||
table = tables.slave_table(slaves)
|
||||
output = str(table)
|
||||
output = six.text_type(table)
|
||||
if output:
|
||||
emitter.publish(output)
|
||||
else:
|
||||
|
||||
@@ -2,6 +2,7 @@ import subprocess
|
||||
|
||||
import dcoscli
|
||||
import docopt
|
||||
import six
|
||||
from dcos import cmds, emitting, marathon, mesos, util
|
||||
from dcos.errors import DCOSException, DefaultError
|
||||
from dcoscli import log, tables
|
||||
@@ -92,7 +93,7 @@ def _service(inactive, completed, is_json):
|
||||
emitter.publish([service.dict() for service in services])
|
||||
else:
|
||||
table = tables.service_table(services)
|
||||
output = str(table)
|
||||
output = six.text_type(table)
|
||||
if output:
|
||||
emitter.publish(output)
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import posixpath
|
||||
|
||||
import dcoscli
|
||||
import docopt
|
||||
import six
|
||||
from dcos import cmds, emitting, mesos, util
|
||||
from dcos.errors import DCOSException, DCOSHTTPException, DefaultError
|
||||
from dcoscli import log, tables
|
||||
@@ -94,7 +95,7 @@ def _task(fltr, completed, json_):
|
||||
emitter.publish([task.dict() for task in tasks])
|
||||
else:
|
||||
table = tables.task_table(tasks)
|
||||
output = str(table)
|
||||
output = six.text_type(table)
|
||||
if output:
|
||||
emitter.publish(output)
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ def publish_table(emitter, objs, table_fn, json_):
|
||||
emitter.publish(objs)
|
||||
else:
|
||||
table = table_fn(objs)
|
||||
output = str(table)
|
||||
output = six.text_type(table)
|
||||
if output:
|
||||
emitter.publish(output)
|
||||
|
||||
@@ -160,7 +160,7 @@ def _page(output, pager_command=None):
|
||||
:type pager_command: str
|
||||
"""
|
||||
|
||||
output = str(output)
|
||||
output = six.text_type(output)
|
||||
|
||||
if pager_command is None:
|
||||
pager_command = 'less -R'
|
||||
|
||||
@@ -431,7 +431,9 @@ def _format_validation_error(error):
|
||||
message = 'Error: {}\n'.format(error_message)
|
||||
if len(error.absolute_path) > 0:
|
||||
message += 'Path: {}\n'.format(
|
||||
'.'.join([str(path) for path in error.absolute_path]))
|
||||
'.'.join(
|
||||
[six.text_type(path)
|
||||
for path in error.absolute_path]))
|
||||
message += 'Value: {}'.format(json.dumps(error.instance))
|
||||
|
||||
return message
|
||||
@@ -478,7 +480,7 @@ def create_schema(obj):
|
||||
else:
|
||||
raise ValueError(
|
||||
'Cannot create schema with object {} of unrecognized type'
|
||||
.format(str(obj)))
|
||||
.format(six.text_type(obj)))
|
||||
|
||||
|
||||
def list_to_err(errs):
|
||||
|
||||
Reference in New Issue
Block a user