diff options
| author | Daniel Nephin <dnephin@gmail.com> | 2015-10-26 17:12:29 -0400 |
|---|---|---|
| committer | Daniel Nephin <dnephin@gmail.com> | 2015-10-26 17:22:14 -0400 |
| commit | 417c80057bed70a4e6a39c3f04c13615b4300f52 (patch) | |
| tree | 54c493b96585584a5ae3c60cf962a75a2608761c /docker | |
| parent | 0234ddebf30b2c979d0fb75ea72280e4f35fec35 (diff) | |
| download | docker-py-417c80057bed70a4e6a39c3f04c13615b4300f52.tar.gz | |
Support unicode commands.
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
Diffstat (limited to 'docker')
| -rw-r--r-- | docker/api/exec_api.py | 4 | ||||
| -rw-r--r-- | docker/utils/__init__.py | 2 | ||||
| -rw-r--r-- | docker/utils/utils.py | 10 |
3 files changed, 10 insertions, 6 deletions
diff --git a/docker/api/exec_api.py b/docker/api/exec_api.py index c66b9dd..e64a40c 100644 --- a/docker/api/exec_api.py +++ b/docker/api/exec_api.py @@ -1,5 +1,3 @@ -import shlex - import six from .. import errors @@ -20,7 +18,7 @@ class ExecApiMixin(object): 'User-specific exec is not supported in API < 1.19' ) if isinstance(cmd, six.string_types): - cmd = shlex.split(str(cmd)) + cmd = utils.split_command(cmd) data = { 'Container': container, diff --git a/docker/utils/__init__.py b/docker/utils/__init__.py index 92e03e9..e27700e 100644 --- a/docker/utils/__init__.py +++ b/docker/utils/__init__.py @@ -3,7 +3,7 @@ from .utils import ( mkbuildcontext, tar, exclude_paths, parse_repository_tag, parse_host, kwargs_from_env, convert_filters, create_host_config, create_container_config, parse_bytes, ping_registry, parse_env_file, - version_lt, version_gte, decode_json_header + version_lt, version_gte, decode_json_header, split_command, ) # flake8: noqa from .types import Ulimit, LogConfig # flake8: noqa diff --git a/docker/utils/utils.py b/docker/utils/utils.py index 89837b7..4d2968a 100644 --- a/docker/utils/utils.py +++ b/docker/utils/utils.py @@ -673,6 +673,12 @@ def parse_env_file(env_file): return environment +def split_command(command): + if six.PY2: + command = command.encode('utf-8') + return shlex.split(command) + + def create_container_config( version, image, command, hostname=None, user=None, detach=False, stdin_open=False, tty=False, mem_limit=None, ports=None, environment=None, @@ -682,10 +688,10 @@ def create_container_config( labels=None, volume_driver=None ): if isinstance(command, six.string_types): - command = shlex.split(str(command)) + command = split_command(command) if isinstance(entrypoint, six.string_types): - entrypoint = shlex.split(str(entrypoint)) + entrypoint = split_command(entrypoint) if isinstance(environment, dict): environment = [ |
