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
0fd70b47
Kaydet (Commit)
0fd70b47
authored
Nis 27, 2015
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Properly implement exec API
üst
2b153a63
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
5 deletions
+48
-5
client.py
docker/client.py
+48
-5
No files found.
docker/client.py
Dosyayı görüntüle @
0fd70b47
...
...
@@ -17,6 +17,7 @@ import os
import
re
import
shlex
import
struct
import
warnings
from
datetime
import
datetime
import
requests
...
...
@@ -515,6 +516,18 @@ class Client(requests.Session):
@check_resource
def
execute
(
self
,
container
,
cmd
,
detach
=
False
,
stdout
=
True
,
stderr
=
True
,
stream
=
False
,
tty
=
False
):
warnings
.
warn
(
'Client.execute is being deprecated. Please use exec_create & '
'exec_start instead'
,
DeprecationWarning
)
create_res
=
self
.
exec_create
(
container
,
cmd
,
detach
,
stdout
,
stderr
,
tty
)
return
self
.
exec_start
(
create_res
,
detach
,
tty
,
stream
)
def
exec_create
(
self
,
container
,
cmd
,
detach
=
False
,
stdout
=
True
,
stderr
=
True
,
tty
=
False
):
if
utils
.
compare_version
(
'1.15'
,
self
.
_version
)
<
0
:
raise
errors
.
InvalidVersion
(
'Exec is not supported in API < 1.15'
)
if
isinstance
(
container
,
dict
):
...
...
@@ -534,14 +547,44 @@ class Client(requests.Session):
'Cmd'
:
cmd
}
# create the command
url
=
self
.
_url
(
'/containers/{0}/exec'
.
format
(
container
))
res
=
self
.
_post_json
(
url
,
data
=
data
)
self
.
_raise_for_status
(
res
)
return
self
.
_result
(
res
,
True
)
def
exec_inspect
(
self
,
exec_id
):
if
utils
.
compare_version
(
'1.15'
,
self
.
_version
)
<
0
:
raise
errors
.
InvalidVersion
(
'Exec is not supported in API < 1.15'
)
if
isinstance
(
exec_id
,
dict
):
exec_id
=
exec_id
.
get
(
'Id'
)
res
=
self
.
_get
(
self
.
_url
(
"/exec/{0}/json"
.
format
(
exec_id
)))
return
self
.
_result
(
res
,
True
)
def
exec_resize
(
self
,
exec_id
,
height
=
None
,
width
=
None
):
if
utils
.
compare_version
(
'1.15'
,
self
.
_version
)
<
0
:
raise
errors
.
InvalidVersion
(
'Exec is not supported in API < 1.15'
)
if
isinstance
(
exec_id
,
dict
):
exec_id
=
exec_id
.
get
(
'Id'
)
data
=
{
'h'
:
height
,
'w'
:
width
}
res
=
self
.
_post_json
(
self
.
_url
(
'exec/{0}/resize'
.
format
(
exec_id
)),
data
)
res
.
raise_for_status
()
def
exec_start
(
self
,
exec_id
,
detach
=
False
,
tty
=
False
,
stream
=
False
):
if
utils
.
compare_version
(
'1.15'
,
self
.
_version
)
<
0
:
raise
errors
.
InvalidVersion
(
'Exec is not supported in API < 1.15'
)
if
isinstance
(
exec_id
,
dict
):
exec_id
=
exec_id
.
get
(
'Id'
)
data
=
{
'Tty'
:
tty
,
'Detach'
:
detach
}
# start the command
cmd_id
=
res
.
json
()
.
get
(
'Id'
)
res
=
self
.
_post_json
(
self
.
_url
(
'/exec/{0}/start'
.
format
(
cmd_id
)),
res
=
self
.
_post_json
(
self
.
_url
(
'/exec/{0}/start'
.
format
(
exec_id
)),
data
=
data
,
stream
=
stream
)
self
.
_raise_for_status
(
res
)
if
stream
:
...
...
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