diff options
author | Jhon Honce <jhonce@redhat.com> | 2018-07-10 12:12:59 -0700 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-07-12 01:38:30 +0000 |
commit | 86154b6538c1fec69fde14f2d4b35c31dcc10b35 (patch) | |
tree | 8c83e9dcd85da19cbf34ed894894a2dc4bdb1c9f /contrib/python/examples/eg_attach.py | |
parent | 7f3f49139694e447a05522efce97d3f8516d0ea2 (diff) | |
download | podman-86154b6538c1fec69fde14f2d4b35c31dcc10b35.tar.gz podman-86154b6538c1fec69fde14f2d4b35c31dcc10b35.tar.bz2 podman-86154b6538c1fec69fde14f2d4b35c31dcc10b35.zip |
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
Diffstat (limited to 'contrib/python/examples/eg_attach.py')
-rw-r--r-- | contrib/python/examples/eg_attach.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/contrib/python/examples/eg_attach.py b/contrib/python/examples/eg_attach.py index f8008163f..f5070dc53 100644 --- a/contrib/python/examples/eg_attach.py +++ b/contrib/python/examples/eg_attach.py @@ -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.') |