Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
docker-py
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
docker-py
Commits
417c8005
Kaydet (Commit)
417c8005
authored
Eki 26, 2015
tarafından
Daniel Nephin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Support unicode commands.
Signed-off-by:
Daniel Nephin
<
dnephin@gmail.com
>
üst
0234ddeb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
7 deletions
+24
-7
exec_api.py
docker/api/exec_api.py
+1
-3
__init__.py
docker/utils/__init__.py
+1
-1
utils.py
docker/utils/utils.py
+8
-2
utils_test.py
tests/unit/utils_test.py
+14
-1
No files found.
docker/api/exec_api.py
Dosyayı görüntüle @
417c8005
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
,
...
...
docker/utils/__init__.py
Dosyayı görüntüle @
417c8005
...
...
@@ -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
...
...
docker/utils/utils.py
Dosyayı görüntüle @
417c8005
...
...
@@ -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
=
s
hlex
.
split
(
str
(
command
)
)
command
=
s
plit_command
(
command
)
if
isinstance
(
entrypoint
,
six
.
string_types
):
entrypoint
=
s
hlex
.
split
(
str
(
entrypoint
)
)
entrypoint
=
s
plit_command
(
entrypoint
)
if
isinstance
(
environment
,
dict
):
environment
=
[
...
...
tests/unit/utils_test.py
Dosyayı görüntüle @
417c8005
...
...
@@ -17,7 +17,8 @@ from docker.errors import DockerException
from
docker.utils
import
(
parse_repository_tag
,
parse_host
,
convert_filters
,
kwargs_from_env
,
create_host_config
,
Ulimit
,
LogConfig
,
parse_bytes
,
parse_env_file
,
exclude_paths
,
convert_volume_binds
,
decode_json_header
,
tar
exclude_paths
,
convert_volume_binds
,
decode_json_header
,
tar
,
split_command
,
)
from
docker.utils.ports
import
build_port_bindings
,
split_port
...
...
@@ -389,6 +390,18 @@ class UtilsTest(base.BaseTestCase):
self
.
assertEqual
(
obj
,
decoded_data
)
class
SplitCommandTest
(
base
.
BaseTestCase
):
@pytest.mark.skipif
(
six
.
PY2
,
reason
=
"shlex doesn't support unicode in py2"
)
def
test_split_command_with_unicode
(
self
):
self
.
assertEqual
(
split_command
(
'echo μ'
),
[
'echo'
,
'μ'
])
@pytest.mark.skipif
(
six
.
PY3
,
reason
=
"shlex doesn't support unicode in py2"
)
def
test_split_command_with_bytes
(
self
):
expected
=
[
'echo'
,
u'μ'
.
encode
(
'utf-8'
)]
self
.
assertEqual
(
split_command
(
u'echo μ'
),
expected
)
class
PortsTest
(
base
.
BaseTestCase
):
def
test_split_port_with_host_ip
(
self
):
internal_port
,
external_port
=
split_port
(
"127.0.0.1:1000:2000"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment