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
6e6eaece
Kaydet (Commit)
6e6eaece
authored
Ock 26, 2018
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Return tuple instead of dict in exec_run
Signed-off-by:
Joffrey F
<
joffrey@docker.com
>
üst
b0cc4b55
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
14 deletions
+13
-14
containers.py
docker/models/containers.py
+4
-7
models_containers_test.py
tests/integration/models_containers_test.py
+3
-3
models_containers_test.py
tests/unit/models_containers_test.py
+6
-4
No files found.
docker/models/containers.py
Dosyayı görüntüle @
6e6eaece
...
...
@@ -150,13 +150,13 @@ class Container(Model):
workdir (str): Path to working directory for this exec session
Returns:
dict:
(tuple): A tuple of (exit_code, output)
exit_code: (int):
Exit code for the executed command
output: (generator or str):
If ``stream=True``, a generator yielding response chunks.
If ``socket=True``, a socket object for the connection.
A string containing response data otherwise.
exit_code: (int):
Exited code of execution
Raises:
:py:class:`docker.errors.APIError`
...
...
@@ -173,10 +173,7 @@ class Container(Model):
exit_code
=
0
if
stream
is
False
:
exit_code
=
self
.
client
.
api
.
exec_inspect
(
resp
[
'Id'
])[
'ExitCode'
]
return
{
'exit_code'
:
exit_code
,
'output'
:
exec_output
}
return
(
exit_code
,
exec_output
)
def
export
(
self
):
"""
...
...
tests/integration/models_containers_test.py
Dosyayı görüntüle @
6e6eaece
...
...
@@ -189,8 +189,8 @@ class ContainerTest(BaseIntegrationTest):
)
self
.
tmp_containers
.
append
(
container
.
id
)
exec_output
=
container
.
exec_run
(
"cat /test"
)
assert
exec_output
[
"output"
]
==
b
"hello
\n
"
assert
exec_output
[
"exit_code"
]
==
0
assert
exec_output
[
0
]
==
0
assert
exec_output
[
1
]
==
b
"hello
\n
"
def
test_exec_run_failed
(
self
):
client
=
docker
.
from_env
(
version
=
TEST_API_VERSION
)
...
...
@@ -199,7 +199,7 @@ class ContainerTest(BaseIntegrationTest):
)
self
.
tmp_containers
.
append
(
container
.
id
)
exec_output
=
container
.
exec_run
(
"docker ps"
)
assert
exec_output
[
"exit_code"
]
==
126
assert
exec_output
[
0
]
==
126
def
test_kill
(
self
):
client
=
docker
.
from_env
(
version
=
TEST_API_VERSION
)
...
...
tests/unit/models_containers_test.py
Dosyayı görüntüle @
6e6eaece
...
...
@@ -400,13 +400,15 @@ class ContainerTest(unittest.TestCase):
client
.
api
.
exec_start
.
assert_called_with
(
FAKE_EXEC_ID
,
detach
=
False
,
tty
=
False
,
stream
=
True
,
socket
=
False
)
def
test_exec_run_failure
(
self
):
client
=
make_fake_client
()
container
=
client
.
containers
.
get
(
FAKE_CONTAINER_ID
)
container
.
exec_run
(
"docker ps"
,
privileged
=
True
,
stream
=
False
)
client
.
api
.
exec_create
.
assert_called_with
(
FAKE_CONTAINER_ID
,
"docker ps"
,
stdout
=
True
,
stderr
=
True
,
stdin
=
False
,
tty
=
False
,
privileged
=
True
,
user
=
''
,
environment
=
None
)
client
.
api
.
exec_start
.
assert_called_with
(
FAKE_EXEC_ID
,
detach
=
False
,
tty
=
False
,
stream
=
False
,
socket
=
False
stdin
=
False
,
tty
=
False
,
privileged
=
True
,
user
=
''
,
environment
=
None
,
workdir
=
None
)
client
.
api
.
exec_start
.
assert_called_with
(
FAKE_EXEC_ID
,
detach
=
False
,
tty
=
False
,
stream
=
False
,
socket
=
False
...
...
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