From bd938b5879734cc061676e677dcdb3c147ff125c Mon Sep 17 00:00:00 2001 From: Aanand Prasad Date: Wed, 6 Nov 2013 17:21:41 +0000 Subject: [PATCH] Use websockets by passing 'ws' param to attach_socket --- docker/client.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docker/client.py b/docker/client.py index 78f7abcf3..d1a7f9cec 100644 --- a/docker/client.py +++ b/docker/client.py @@ -140,7 +140,10 @@ def _post_json(self, url, data, **kwargs): kwargs['headers']['Content-Type'] = 'application/json' return self.post(url, json.dumps(data2), **kwargs) - def attach_socket(self, container, params=None): + def attach_socket(self, container, params=None, ws=False): + if ws: + return self._attach_websocket(container, params) + if isinstance(container, dict): container = container.get('Id') u = self._url("/containers/{0}/attach".format(container)) @@ -151,7 +154,7 @@ def attach_socket(self, container, params=None): # eventually block return res.raw._fp.fp._sock - def attach_websocket(self, container, params=None): + def _attach_websocket(self, container, params=None): url = self._url("/containers/{0}/attach/ws".format(container)) req = requests.Request("POST", url, params=self._attach_params(params)) full_url = req.prepare().url