@@ -41,7 +41,7 @@ def attach(self, container, stdout=True, stderr=True,
41
41
'stderr' : stderr and 1 or 0 ,
42
42
'stream' : stream and 1 or 0 ,
43
43
}
44
- u = self ._url ("/containers/{0}/attach" . format ( container ) )
44
+ u = self ._url ("/containers/{0}/attach" , container )
45
45
response = self ._post (u , params = params , stream = stream )
46
46
47
47
return self ._get_result (container , stream , response )
@@ -58,7 +58,7 @@ def attach_socket(self, container, params=None, ws=False):
58
58
if ws :
59
59
return self ._attach_websocket (container , params )
60
60
61
- u = self ._url ("/containers/{0}/attach" . format ( container ) )
61
+ u = self ._url ("/containers/{0}/attach" , container )
62
62
return self ._get_raw_response_socket (self .post (
63
63
u , None , params = self ._attach_params (params ), stream = True ))
64
64
@@ -275,8 +275,9 @@ def create_host_config(self, *args, **kwargs):
275
275
276
276
@check_resource
277
277
def diff (self , container ):
278
- return self ._result (self ._get (self ._url ("/containers/{0}/changes" .
279
- format (container ))), True )
278
+ return self ._result (
279
+ self ._get (self ._url ("/containers/{0}/changes" , container )), True
280
+ )
280
281
281
282
def events (self , since = None , until = None , filters = None , decode = None ):
282
283
if isinstance (since , datetime ):
@@ -326,7 +327,7 @@ def exec_create(self, container, cmd, stdout=True, stderr=True, tty=False,
326
327
'Cmd' : cmd
327
328
}
328
329
329
- url = self ._url ('/containers/{0}/exec' . format ( container ) )
330
+ url = self ._url ('/containers/{0}/exec' , container )
330
331
res = self ._post_json (url , data = data )
331
332
return self ._result (res , True )
332
333
@@ -337,7 +338,7 @@ def exec_inspect(self, exec_id):
337
338
)
338
339
if isinstance (exec_id , dict ):
339
340
exec_id = exec_id .get ('Id' )
340
- res = self ._get (self ._url ("/exec/{0}/json" . format ( exec_id ) ))
341
+ res = self ._get (self ._url ("/exec/{0}/json" , exec_id ))
341
342
return self ._result (res , True )
342
343
343
344
def exec_resize (self , exec_id , height = None , width = None ):
@@ -347,7 +348,7 @@ def exec_resize(self, exec_id, height=None, width=None):
347
348
exec_id = exec_id .get ('Id' )
348
349
349
350
params = {'h' : height , 'w' : width }
350
- url = self ._url ("/exec/{0}/resize" . format ( exec_id ) )
351
+ url = self ._url ("/exec/{0}/resize" , exec_id )
351
352
res = self ._post (url , params = params )
352
353
self ._raise_for_status (res )
353
354
@@ -362,27 +363,28 @@ def exec_start(self, exec_id, detach=False, tty=False, stream=False):
362
363
'Detach' : detach
363
364
}
364
365
365
- res = self ._post_json (self ._url ('/exec/{0}/start' .format (exec_id )),
366
- data = data , stream = stream )
366
+ res = self ._post_json (
367
+ self ._url ('/exec/{0}/start' , exec_id ), data = data , stream = stream
368
+ )
367
369
return self ._get_result_tty (stream , res , tty )
368
370
369
371
@check_resource
370
372
def export (self , container ):
371
- res = self ._get (self ._url ("/containers/{0}/export" .format (container )),
372
- stream = True )
373
+ res = self ._get (
374
+ self ._url ("/containers/{0}/export" , container ), stream = True
375
+ )
373
376
self ._raise_for_status (res )
374
377
return res .raw
375
378
376
379
@check_resource
377
380
def get_image (self , image ):
378
- res = self ._get (self ._url ("/images/{0}/get" .format (image )),
379
- stream = True )
381
+ res = self ._get (self ._url ("/images/{0}/get" , image ), stream = True )
380
382
self ._raise_for_status (res )
381
383
return res .raw
382
384
383
385
@check_resource
384
386
def history (self , image ):
385
- res = self ._get (self ._url ("/images/{0}/history" . format ( image ) ))
387
+ res = self ._get (self ._url ("/images/{0}/history" , image ))
386
388
return self ._result (res , True )
387
389
388
390
def images (self , name = None , quiet = False , all = False , viz = False ,
@@ -496,7 +498,7 @@ def insert(self, image, url, path):
496
498
raise errors .DeprecatedMethod (
497
499
'insert is not available for API version >=1.12'
498
500
)
499
- api_url = self ._url ("/images/{0}/insert" . format ( image ) )
501
+ api_url = self ._url ("/images/{0}/insert" , image )
500
502
params = {
501
503
'url' : url ,
502
504
'path' : path
@@ -506,21 +508,18 @@ def insert(self, image, url, path):
506
508
@check_resource
507
509
def inspect_container (self , container ):
508
510
return self ._result (
509
- self ._get (self ._url ("/containers/{0}/json" . format ( container ))),
510
- True )
511
+ self ._get (self ._url ("/containers/{0}/json" , container )), True
512
+ )
511
513
512
514
@check_resource
513
515
def inspect_image (self , image ):
514
516
return self ._result (
515
- self ._get (
516
- self ._url ("/images/{0}/json" .format (image .replace ('/' , '%2F' )))
517
- ),
518
- True
517
+ self ._get (self ._url ("/images/{0}/json" , image )), True
519
518
)
520
519
521
520
@check_resource
522
521
def kill (self , container , signal = None ):
523
- url = self ._url ("/containers/{0}/kill" . format ( container ) )
522
+ url = self ._url ("/containers/{0}/kill" , container )
524
523
params = {}
525
524
if signal is not None :
526
525
params ['signal' ] = signal
@@ -583,7 +582,7 @@ def logs(self, container, stdout=True, stderr=True, stream=False,
583
582
if tail != 'all' and (not isinstance (tail , int ) or tail <= 0 ):
584
583
tail = 'all'
585
584
params ['tail' ] = tail
586
- url = self ._url ("/containers/{0}/logs" . format ( container ) )
585
+ url = self ._url ("/containers/{0}/logs" , container )
587
586
res = self ._get (url , params = params , stream = stream )
588
587
return self ._get_result (container , stream , res )
589
588
return self .attach (
@@ -596,7 +595,7 @@ def logs(self, container, stdout=True, stderr=True, stream=False,
596
595
597
596
@check_resource
598
597
def pause (self , container ):
599
- url = self ._url ('/containers/{0}/pause' . format ( container ) )
598
+ url = self ._url ('/containers/{0}/pause' , container )
600
599
res = self ._post (url )
601
600
self ._raise_for_status (res )
602
601
@@ -605,7 +604,7 @@ def ping(self):
605
604
606
605
@check_resource
607
606
def port (self , container , private_port ):
608
- res = self ._get (self ._url ("/containers/{0}/json" . format ( container ) ))
607
+ res = self ._get (self ._url ("/containers/{0}/json" , container ))
609
608
self ._raise_for_status (res )
610
609
json_ = res .json ()
611
610
s_port = str (private_port )
@@ -692,7 +691,7 @@ def push(self, repository, tag=None, stream=False,
692
691
if not tag :
693
692
repository , tag = utils .parse_repository_tag (repository )
694
693
registry , repo_name = auth .resolve_repository_name (repository )
695
- u = self ._url ("/images/{0}/push" . format ( repository ) )
694
+ u = self ._url ("/images/{0}/push" , repository )
696
695
params = {
697
696
'tag' : tag
698
697
}
@@ -725,14 +724,15 @@ def push(self, repository, tag=None, stream=False,
725
724
@check_resource
726
725
def remove_container (self , container , v = False , link = False , force = False ):
727
726
params = {'v' : v , 'link' : link , 'force' : force }
728
- res = self ._delete (self ._url ("/containers/" + container ),
729
- params = params )
727
+ res = self ._delete (
728
+ self ._url ("/containers/{0}" , container ), params = params
729
+ )
730
730
self ._raise_for_status (res )
731
731
732
732
@check_resource
733
733
def remove_image (self , image , force = False , noprune = False ):
734
734
params = {'force' : force , 'noprune' : noprune }
735
- res = self ._delete (self ._url ("/images/" + image ), params = params )
735
+ res = self ._delete (self ._url ("/images/{0}" , image ), params = params )
736
736
self ._raise_for_status (res )
737
737
738
738
@check_resource
@@ -741,29 +741,30 @@ def rename(self, container, name):
741
741
raise errors .InvalidVersion (
742
742
'rename was only introduced in API version 1.17'
743
743
)
744
- url = self ._url ("/containers/{0}/rename" . format ( container ) )
744
+ url = self ._url ("/containers/{0}/rename" , container )
745
745
params = {'name' : name }
746
746
res = self ._post (url , params = params )
747
747
self ._raise_for_status (res )
748
748
749
749
@check_resource
750
750
def resize (self , container , height , width ):
751
751
params = {'h' : height , 'w' : width }
752
- url = self ._url ("/containers/{0}/resize" . format ( container ) )
752
+ url = self ._url ("/containers/{0}/resize" , container )
753
753
res = self ._post (url , params = params )
754
754
self ._raise_for_status (res )
755
755
756
756
@check_resource
757
757
def restart (self , container , timeout = 10 ):
758
758
params = {'t' : timeout }
759
- url = self ._url ("/containers/{0}/restart" . format ( container ) )
759
+ url = self ._url ("/containers/{0}/restart" , container )
760
760
res = self ._post (url , params = params )
761
761
self ._raise_for_status (res )
762
762
763
763
def search (self , term ):
764
- return self ._result (self ._get (self ._url ("/images/search" ),
765
- params = {'term' : term }),
766
- True )
764
+ return self ._result (
765
+ self ._get (self ._url ("/images/search" ), params = {'term' : term }),
766
+ True
767
+ )
767
768
768
769
@check_resource
769
770
def start (self , container , binds = None , port_bindings = None , lxc_conf = None ,
@@ -829,7 +830,7 @@ def start(self, container, binds=None, port_bindings=None, lxc_conf=None,
829
830
)
830
831
start_config = self .create_host_config (** start_config_kwargs )
831
832
832
- url = self ._url ("/containers/{0}/start" . format ( container ) )
833
+ url = self ._url ("/containers/{0}/start" , container )
833
834
res = self ._post_json (url , data = start_config )
834
835
self ._raise_for_status (res )
835
836
@@ -839,13 +840,13 @@ def stats(self, container, decode=None):
839
840
raise errors .InvalidVersion (
840
841
'Stats retrieval is not supported in API < 1.17!' )
841
842
842
- url = self ._url ("/containers/{0}/stats" . format ( container ) )
843
+ url = self ._url ("/containers/{0}/stats" , container )
843
844
return self ._stream_helper (self ._get (url , stream = True ), decode = decode )
844
845
845
846
@check_resource
846
847
def stop (self , container , timeout = 10 ):
847
848
params = {'t' : timeout }
848
- url = self ._url ("/containers/{0}/stop" . format ( container ) )
849
+ url = self ._url ("/containers/{0}/stop" , container )
849
850
850
851
res = self ._post (url , params = params ,
851
852
timeout = (timeout + (self .timeout or 0 )))
@@ -858,14 +859,14 @@ def tag(self, image, repository, tag=None, force=False):
858
859
'repo' : repository ,
859
860
'force' : 1 if force else 0
860
861
}
861
- url = self ._url ("/images/{0}/tag" . format ( image ) )
862
+ url = self ._url ("/images/{0}/tag" , image )
862
863
res = self ._post (url , params = params )
863
864
self ._raise_for_status (res )
864
865
return res .status_code == 201
865
866
866
867
@check_resource
867
868
def top (self , container ):
868
- u = self ._url ("/containers/{0}/top" . format ( container ) )
869
+ u = self ._url ("/containers/{0}/top" , container )
869
870
return self ._result (self ._get (u ), True )
870
871
871
872
def version (self , api_version = True ):
@@ -874,13 +875,13 @@ def version(self, api_version=True):
874
875
875
876
@check_resource
876
877
def unpause (self , container ):
877
- url = self ._url ('/containers/{0}/unpause' . format ( container ) )
878
+ url = self ._url ('/containers/{0}/unpause' , container )
878
879
res = self ._post (url )
879
880
self ._raise_for_status (res )
880
881
881
882
@check_resource
882
883
def wait (self , container , timeout = None ):
883
- url = self ._url ("/containers/{0}/wait" . format ( container ) )
884
+ url = self ._url ("/containers/{0}/wait" , container )
884
885
res = self ._post (url , timeout = timeout )
885
886
self ._raise_for_status (res )
886
887
json_ = res .json ()
0 commit comments