Refactor attach()/start() after podman changes

* Update examples
* Update/Clean up unittests
* Add Mixins for container attach()/start()

Signed-off-by: Jhon Honce <jhonce@redhat.com>

Closes: #1080
Approved by: baude
This commit is contained in:
Jhon Honce
2018-07-10 12:12:59 -07:00
committed by Atomic Bot
parent 7f3f491396
commit 86154b6538
7 changed files with 132 additions and 90 deletions

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""Example: Run Alpine container and attach."""
"""Example: Run top on Alpine container."""
import podman
@ -8,10 +8,11 @@ print('{}\n'.format(__doc__))
with podman.Client() as client:
id = client.images.pull('alpine:latest')
img = client.images.get(id)
cntr = img.create()
cntr.start()
cntr = img.create(detach=True, tty=True, command=['/usr/bin/top'])
cntr.attach(eot=4)
try:
cntr.attach()
except BrokenPipeError:
print('Container disconnected.')
cntr.start()
print()
except (BrokenPipeError, KeyboardInterrupt):
print('\nContainer disconnected.')