Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions dockerpty/pty.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def start(self, sockets=None, **kwargs):
pumps.append(io.Pump(pty_stderr, io.Stream(self.stderr), propagate_close=False))

if not self._container_info()['State']['Running']:
self.client.start(self.container, **kwargs)
self.container.start(**kwargs)

return pumps

Expand Down Expand Up @@ -175,9 +175,8 @@ def sockets(self):

def attach_socket(key):
if info['Config']['Attach{0}'.format(key.capitalize())]:
socket = self.client.attach_socket(
self.container,
{key: 1, 'stream': 1, 'logs': self.logs},
socket = self.container.attach_socket(
params={key: 1, 'stream': 1, 'logs': self.logs}
)
stream = io.Stream(socket)

Expand All @@ -194,19 +193,19 @@ def resize(self, height, width, **kwargs):
"""
resize pty within container
"""
self.client.resize(self.container, height=height, width=width)
self.container.resize(height=height, width=width)

def _container_info(self):
"""
Thin wrapper around client.inspect_container().
"""

return self.client.inspect_container(self.container)
self.container.reload()
return self.container.attrs


def exec_create(client, container, command, interactive=True):
exec_id = client.exec_create(container, command, tty=interactive, stdin=interactive)
return exec_id
exec_id = client.api.exec_create(container, command, tty=interactive, stdin=interactive)
return exec_id['Id']


class ExecOperation(Operation):
Expand Down Expand Up @@ -257,7 +256,7 @@ def sockets(self):
"""
Return a single socket which is processing all I/O to exec
"""
socket = self.client.exec_start(self.exec_id, socket=True, tty=self.interactive)
socket = self.client.api.exec_start(self.exec_id, socket=True, tty=self.interactive)
stream = io.Stream(socket)
if self.is_process_tty():
return stream
Expand All @@ -268,7 +267,7 @@ def resize(self, height, width, **kwargs):
"""
resize pty of an execed process
"""
self.client.exec_resize(self.exec_id, height=height, width=width)
self.client.api.exec_resize(self.exec_id, height=height, width=width)

def is_process_tty(self):
"""
Expand All @@ -281,7 +280,7 @@ def _exec_info(self):
Caching wrapper around client.exec_inspect
"""
if self._info is None:
self._info = self.client.exec_inspect(self.exec_id)
self._info = self.client.api.exec_inspect(self.exec_id)
return self._info


Expand Down