diff options
author | Felipe Sateler <fsateler@debian.org> | 2015-05-20 20:25:44 -0300 |
---|---|---|
committer | Felipe Sateler <fsateler@debian.org> | 2015-05-20 20:25:44 -0300 |
commit | b2b8e8e34716349fe748e1616888106301575a81 (patch) | |
tree | dde4aef1d4368fcb00259f9130a2430e95bcde93 /debian | |
parent | b34a182bae203af11a5120310e4dffcbcdaa79d4 (diff) |
Revert "Bundle a version of dockerpty until it is packaged"
This reverts commit 1d5c44ded34c4c68d0b3d716932a66a13f6a70ae.
Conflicts:
debian/rules
Diffstat (limited to 'debian')
26 files changed, 1 insertions, 2244 deletions
diff --git a/debian/bundle/dockerpty-0.3.2/.gitignore b/debian/bundle/dockerpty-0.3.2/.gitignore deleted file mode 100644 index 6cf08cf5..00000000 --- a/debian/bundle/dockerpty-0.3.2/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -*.pyc -*.egg-info -build/ -dist/ -.tox/ diff --git a/debian/bundle/dockerpty-0.3.2/.travis.yml b/debian/bundle/dockerpty-0.3.2/.travis.yml deleted file mode 100644 index 8cd0c076..00000000 --- a/debian/bundle/dockerpty-0.3.2/.travis.yml +++ /dev/null @@ -1,135 +0,0 @@ -# dockerpty: .travis.yml -# -# Copyright 2014 Chris Corbyn <chris@w3style.co.uk> -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -language: python -python: [ "2.7" ] - -before_install: | - # needed for the UML container - sudo apt-get install -qq -y slirp aufs-tools cgroup-lite - - # prepare docker dir for aufs mount - sudo mkdir -p /var/lib/docker - - # download usermode linux kernel for docker - curl -sLo linux https://github.com/jpetazzo/sekexe/raw/master/uml - chmod +x linux - - # download docker - curl -sLo docker \ - https://get.docker.io/builds/Linux/x86_64/docker-1.0.0 - chmod +x docker - - - # --------------------------------------------------------------------------- - - - # create tests.sh script - cat > tests.sh <<'BASH' - #!/bin/bash - - # go back to where we were invoked - cd $WORKDIR - - save_and_shutdown() { - # save built for host result - echo $? > /tmp/build.status - # force clean shutdown - halt -f - } - - # make sure we shut down cleanly - trap save_and_shutdown EXIT - - # configure path to include /usr/local - export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin - - # can't do much without proc! - mount -t proc none /proc - - # pseudo-terminal devices - mkdir -p /dev/pts - mount -t devpts none /dev/pts - - # shared memory a good idea - mkdir -p /dev/shm - mount -t tmpfs none /dev/shm - - # sysfs a good idea - mount -t sysfs none /sys - - # pidfiles and such like - mkdir -p /var/run - mount -t tmpfs none /var/run - - # takes the pain out of cgroups - cgroups-mount - - # mount /var/lib/docker with a tmpfs - mount -t tmpfs none /var/lib/docker - - # enable ipv4 forwarding for docker - echo 1 > /proc/sys/net/ipv4/ip_forward - - # configure networking - ip addr add 127.0.0.1 dev lo - ip link set lo up - ip addr add 10.1.1.1/24 dev eth0 - ip link set eth0 up - ip route add default via 10.1.1.254 - - # configure dns (google public) - mkdir -p /run/resolvconf - echo 'nameserver 8.8.8.8' > /run/resolvconf/resolv.conf - mount --bind /run/resolvconf/resolv.conf /etc/resolv.conf - - # start docker backgrounded - ((./docker -d >/dev/null 2>&1 &) &) - sleep 5 - - # activate virtualenv - source $HOME/virtualenv/python2.7/bin/activate - - # run the build - py.test -q tests && behave -c - BASH - - chmod +x tests.sh - - - # --------------------------------------------------------------------------- - - - # create run.sh script - cat > run.sh <<'BASH' - #!/bin/bash - - # assume failure - echo 1 > /tmp/build.status - - # run the build inside UML kernel - ./linux quiet mem=2G rootfstype=hostfs rw \ - eth0=slirp,,/usr/bin/slirp-fullbolt \ - init=$(pwd)/tests.sh WORKDIR=$(pwd) HOME=$HOME - - # grab the build result and use it - exit $(cat /tmp/build.status) - BASH - - chmod +x run.sh - -install: pip install -r requirements-dev.txt -script: ./run.sh diff --git a/debian/bundle/dockerpty-0.3.2/LICENSE.txt b/debian/bundle/dockerpty-0.3.2/LICENSE.txt deleted file mode 100644 index d6456956..00000000 --- a/debian/bundle/dockerpty-0.3.2/LICENSE.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/debian/bundle/dockerpty-0.3.2/MANIFEST.in b/debian/bundle/dockerpty-0.3.2/MANIFEST.in deleted file mode 100644 index 3e677d05..00000000 --- a/debian/bundle/dockerpty-0.3.2/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -include README.md -include LICENSE.txt diff --git a/debian/bundle/dockerpty-0.3.2/README.md b/debian/bundle/dockerpty-0.3.2/README.md deleted file mode 100644 index c4d17c15..00000000 --- a/debian/bundle/dockerpty-0.3.2/README.md +++ /dev/null @@ -1,129 +0,0 @@ -# Docker PTY - -Provides the functionality needed to operate the pseudo-tty (PTY) allocated to -a docker container, using the Python client. - -[![Build Status](https://travis-ci.org/d11wtq/dockerpty.svg?branch=master)] -(https://travis-ci.org/d11wtq/dockerpty) - -## Installation - -Via pip: - -``` -pip install dockerpty -``` - -Dependencies: - - * docker-py>=0.3.2 - -However, this library does not explicitly declare this dependency in PyPi for a -number of reasons. It is assumed you have it installed. - -## Usage - -The following example will run busybox in a docker container and place the user -at the shell prompt via Python. - -This obviously only works when run in a terminal. - -``` python -import docker -import dockerpty - -client = docker.Client() -container = client.create_container( - image='busybox:latest', - stdin_open=True, - tty=True, - command='/bin/sh', -) - -dockerpty.start(client, container) -``` - -Keyword arguments passed to `start()` will be forwarded onto the client to -start the container. - -When the dockerpty is started, control is yielded to the container's PTY until -the container exits, or the container's PTY is closed. - -This is a safe operation and all resources are restored back to their original -states. - -> **Note:** dockerpty does support attaching to non-tty containers to stream -container output, though it is obviously not possible to 'control' the -container if you do not allocate a pseudo-tty. - -If you press `C-p C-q`, the container's PTY will be closed, but the container -will keep running. In other words, you will have detached from the container -and can re-attach with another `dockerpty.start()` call. - -## Tests - -If you want to hack on dockerpty and send a PR, you'll need to run the tests. -In the features/ directory, are features/user stories for how dockerpty is -supposed to work. To run them: - -``` --bash$ pip install -r requirements-dev.txt --bash$ behave features/ -``` - -You'll need to have docker installed and running locally. The tests use busybox -container as a test fixture, so are not too heavy. - -Step definitions are defined in features/steps/. - -There are also unit tests for the parts of the code that are not inherently -dependent on controlling a TTY. To run those: - -``` --bash$ pip install -r requirements-dev.txt --bash$ py.test tests/ -``` - -Travis CI runs this build inside a UML kernel that is new enough to run docker. -Your PR will need to pass the build before I can merge it. - - - Travis CI build: https://travis-ci.org/d11wtq/dockerpty - -## How it works - -In a terminal, the three file descriptors stdin, stdout and stderr are all -connected to the controlling terminal (TTY). When you pass the `tty=True` flag -to docker's `create_container()`, docker allocates a fake TTY inside the -container (a PTY) to which the container's stdin, stdout and stderr are all -connected. - -The docker API provides a way to access the three sockets connected to the PTY. -If with access to the host system's TTY file descriptors and the container's -PTY file descriptors, it is trivial to simply 'pipe' data written to these file -descriptors between the host and the container. Doing this makes the user's -terminal effectively become the pseudo-terminal from inside the container. - -In reality it's a bit more complicated than this, since care must be taken to -put the host terminal into raw mode (where keys such as enter are not -interpreted with any special meaning) and restore it on exit. Additionally, the -container's stdout and stderr streams along with `sys.stdin` must be made -non-blocking so that they can be used with `select()` without blocking the main -process. These attributes are restored on exit. - -The size of a terminal cannot be controlled by sending data to stdin and can -only be controlled by the terminal program itself. Since the pseudo-terminal is -running inside a real terminal, it is import that the size of the PTY be kept -the same as that of the presenting TTY. For this reason, docker provides an API -call to resize the allocated PTY. A SIGWINCH handler is used to detect window -size changes and resize the pseudo-terminal as needed. - -## Contributors - - - Primary author: [Chris Corbyn](https://github.com/d11wtq) - - Collaborator: [Daniel Nephin](https://github.com/dnephin) - - Contributor: [Stephen Moore](https://github.com/delfick) - - Contributor: [Ben Firshman](https://github.com/bfirsh) - -## Copyright & Licensing - -Copyright © 2014 Chris Corbyn. See the LICENSE.txt file for details. diff --git a/debian/bundle/dockerpty-0.3.2/dockerpty/__init__.py b/debian/bundle/dockerpty-0.3.2/dockerpty/__init__.py deleted file mode 100644 index 2d11a8ae..00000000 --- a/debian/bundle/dockerpty-0.3.2/dockerpty/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -# dockerpty. -# -# Copyright 2014 Chris Corbyn <chris@w3style.co.uk> -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from dockerpty.pty import PseudoTerminal - - -def start(client, container, interactive=True): - """ - Present the PTY of the container inside the current process. - - This is just a wrapper for PseudoTerminal(client, container).start() - """ - - PseudoTerminal(client, container, interactive=interactive).start() diff --git a/debian/bundle/dockerpty-0.3.2/dockerpty/io.py b/debian/bundle/dockerpty-0.3.2/dockerpty/io.py deleted file mode 100644 index c31c5401..00000000 --- a/debian/bundle/dockerpty-0.3.2/dockerpty/io.py +++ /dev/null @@ -1,294 +0,0 @@ -# dockerpty: io.py -# -# Copyright 2014 Chris Corbyn <chris@w3style.co.uk> -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os -import fcntl -import errno -import struct -import select as builtin_select - - -def set_blocking(fd, blocking=True): - """ - Set the given file-descriptor blocking or non-blocking. - - Returns the original blocking status. - """ - - old_flag = fcntl.fcntl(fd, fcntl.F_GETFL) - - if blocking: - new_flag = old_flag &~ os.O_NONBLOCK - else: - new_flag = old_flag | os.O_NONBLOCK - - fcntl.fcntl(fd, fcntl.F_SETFL, new_flag) - - return not bool(old_flag & os.O_NONBLOCK) - - -def select(read_streams, timeout=0): - """ - Select the streams from `read_streams` that are ready for reading. - - Uses `select.select()` internally but returns a flat list of streams. - """ - - write_streams = [] - exception_streams = [] - - try: - return builtin_select.select( - read_streams, - write_streams, - exception_streams, - timeout, - )[0] - except builtin_select.error as e: - # POSIX signals interrupt select() - if e[0] == errno.EINTR: - return [] - else: - raise e - - -class Stream(object): - """ - Generic Stream class. - - This is a file-like abstraction on top of os.read() and os.write(), which - add consistency to the reading of sockets and files alike. - """ - - - """ - Recoverable IO/OS Errors. - """ - ERRNO_RECOVERABLE = [ - errno.EINTR, - errno.EDEADLK, - errno.EWOULDBLOCK, - ] - - - def __init__(self, fd): - """ - Initialize the Stream for the file descriptor `fd`. - - The `fd` object must have a `fileno()` method. - """ - self.fd = fd - - - def fileno(self): - """ - Return the fileno() of the file descriptor. - """ - - return self.fd.fileno() - - - def set_blocking(self, value): - if hasattr(self.fd, 'setblocking'): - self.fd.setblocking(value) - return True - else: - return set_blocking(self.fd, value) - - - def read(self, n=4096): - """ - Return `n` bytes of data from the Stream, or None at end of stream. - """ - - try: - if hasattr(self.fd, 'recv'): - return self.fd.recv(n) - return os.read(self.fd.fileno(), n) - except EnvironmentError as e: - if e.errno not in Stream.ERRNO_RECOVERABLE: - raise e - - - def write(self, data): - """ - Write `data` to the Stream. - """ - - if not data: - return None - - while True: - try: - if hasattr(self.fd, 'send'): - self.fd.send(data) - return len(data) - os.write(self.fd.fileno(), data) - return len(data) - except EnvironmentError as e: - if e.errno not in Stream.ERRNO_RECOVERABLE: - raise e - - def __repr__(self): - return "{cls}({fd})".format(cls=type(self).__name__, fd=self.fd) - - -class Demuxer(object): - """ - Wraps a multiplexed Stream to read in data demultiplexed. - - Docker multiplexes streams together when there is no PTY attached, by - sending an 8-byte header, followed by a chunk of data. - - The first 4 bytes of the header denote the stream from which the data came - (i.e. 0x01 = stdout, 0x02 = stderr). Only the first byte of these initial 4 - bytes is used. - - The next 4 bytes indicate the length of the following chunk of data as an - integer in big endian format. This much data must be consumed before the - next 8-byte header is read. - """ - - def __init__(self, stream): - """ - Initialize a new Demuxer reading from `stream`. - """ - - self.stream = stream - self.remain = 0 - - - def fileno(self): - """ - Returns the fileno() of the underlying Stream. - - This is useful for select() to work. - """ - - return self.stream.fileno() - - - def set_blocking(self, value): - return self.stream.set_blocking(value) - - - def read(self, n=4096): - """ - Read up to `n` bytes of data from the Stream, after demuxing. - - Less than `n` bytes of data may be returned depending on the available - payload, but the number of bytes returned will never exceed `n`. - - Because demuxing involves scanning 8-byte headers, the actual amount of - data read from the underlying stream may be greater than `n`. - """ - - size = self._next_packet_size(n) - - if size <= 0: - return - else: - return self.stream.read(size) - - - def write(self, data): - """ - Delegates the the underlying Stream. - """ - - return self.stream.write(data) - - - def _next_packet_size(self, n=0): - size = 0 - - if self.remain > 0: - size = min(n, self.remain) - self.remain -= size - else: - data = self.stream.read(8) - if data is None: - return 0 - if len(data) == 8: - __, actual = struct.unpack('>BxxxL', data) - size = min(n, actual) - self.remain = actual - size - - return size - - def __repr__(self): - return "{cls}({stream})".format(cls=type(self).__name__, - stream=self.stream) - - -class Pump(object): - """ - Stream pump class. - - A Pump wraps two Streams, reading from one and and writing its data into - the other, much like a pipe but manually managed. - - This abstraction is used to facilitate piping data between the file - descriptors associated with the tty and those associated with a container's - allocated pty. - - Pumps are selectable based on the 'read' end of the pipe. - """ - - def __init__(self, from_stream, to_stream): - """ - Initialize a Pump with a Stream to read from and another to write to. - """ - - self.from_stream = from_stream - self.to_stream = to_stream - - - def fileno(self): - """ - Returns the `fileno()` of the reader end of the Pump. - - This is useful to allow Pumps to function with `select()`. - """ - - return self.from_stream.fileno() - - - def set_blocking(self, value): - return self.from_stream.set_blocking(value) - - - def flush(self, n=4096): - """ - Flush `n` bytes of data from the reader Stream to the writer Stream. - - Returns the number of bytes that were actually flushed. A return value - of zero is not an error. - - If EOF has been reached, `None` is returned. - """ - - try: - return self.to_stream.write(self.from_stream.read(n)) - except OSError as e: - if e.errno != errno.EPIPE: - raise e - - def __repr__(self): - return "{cls}(from={from_stream}, to={to_stream})".format( - cls=type(self).__name__, - from_stream=self.from_stream, - to_stream=self.to_stream) diff --git a/debian/bundle/dockerpty-0.3.2/dockerpty/pty.py b/debian/bundle/dockerpty-0.3.2/dockerpty/pty.py deleted file mode 100644 index ea4c1802..00000000 --- a/debian/bundle/dockerpty-0.3.2/dockerpty/pty.py +++ /dev/null @@ -1,239 +0,0 @@ -# dockerpty: pty.py -# -# Copyright 2014 Chris Corbyn <chris@w3style.co.uk> -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import sys -import signal -from ssl import SSLError - -import dockerpty.io as io -import dockerpty.tty as tty - - -class WINCHHandler(object): - """ - WINCH Signal handler to keep the PTY correctly sized. - """ - - def __init__(self, pty): - """ - Initialize a new WINCH handler for the given PTY. - - Initializing a handler has no immediate side-effects. The `start()` - method must be invoked for the signals to be trapped. - """ - - self.pty = pty - self.original_handler = None - - - def __enter__(self): - """ - Invoked on entering a `with` block. - """ - - self.start() - return self - - - def __exit__(self, *_): - """ - Invoked on exiting a `with` block. - """ - - self.stop() - - - def start(self): - """ - Start trapping WINCH signals and resizing the PTY. - - This method saves the previous WINCH handler so it can be restored on - `stop()`. - """ - - def handle(signum, frame): - if signum == signal.SIGWINCH: - self.pty.resize() - - self.original_handler = signal.signal(signal.SIGWINCH, handle) - - - def stop(self): - """ - Stop trapping WINCH signals and restore the previous WINCH handler. - """ - - if self.original_handler is not None: - signal.signal(signal.SIGWINCH, self.original_handler) - - -class PseudoTerminal(object): - """ - Wraps the pseudo-TTY (PTY) allocated to a docker container. - - The PTY is managed via the current process' TTY until it is closed. - - Example: - - import docker - from dockerpty import PseudoTerminal - - client = docker.Client() - container = client.create_container( - image='busybox:latest', - stdin_open=True, - tty=True, - command='/bin/sh', - ) - - # hijacks the current tty until the pty is closed - PseudoTerminal(client, container).start() - - Care is taken to ensure all file descriptors are restored on exit. For - example, you can attach to a running container from within a Python REPL - and when the container exits, the user will be returned to the Python REPL - without adverse effects. - """ - - - def __init__(self, client, container, interactive=True): - """ - Initialize the PTY using the docker.Client instance and container dict. - """ - - self.client = client - self.container = container - self.raw = None - self.interactive = interactive - - - def start(self, **kwargs): - """ - Present the PTY of the container inside the current process. - - This will take over the current process' TTY until the container's PTY - is closed. - """ - - pty_stdin, pty_stdout, pty_stderr = self.sockets() - - - mappings = [ - (pty_stdout, io.Stream(sys.stdout)), - (pty_stderr, io.Stream(sys.stderr)), - ] - - if self.interactive: - mappings.insert(0, (io.Stream(sys.stdin), pty_stdin)) - - pumps = [io.Pump(a, b) for (a, b) in mappings if a and b] - - if not self.container_info()['State']['Running']: - self.client.start(self.container, **kwargs) - - flags = [p.set_blocking(False) for p in pumps] - - try: - with WINCHHandler(self): - self._hijack_tty(pumps) - finally: - if flags: - for (pump, flag) in zip(pumps, flags): - io.set_blocking(pump, flag) - - - def israw(self): - """ - Returns True if the PTY should operate in raw mode. - - If the container was not started with tty=True, this will return False. - """ - - if self.raw is None: - info = self.container_info() - self.raw = sys.stdout.isatty() and info['Config']['Tty'] - - return self.raw - - - def sockets(self): - """ - Returns a tuple of sockets connected to the pty (stdin,stdout,stderr). - - If any of the sockets are not attached in the container, `None` is - returned in the tuple. - """ - - info = self.container_info() - - def attach_socket(key): - if info['Config']['Attach{0}'.format(key.capitalize())]: - socket = self.client.attach_socket( - self.container, - {key: 1, 'stream': 1, 'logs': 1}, - ) - stream = io.Stream(socket) - - if info['Config']['Tty']: - return stream - else: - return io.Demuxer(stream) - else: - return None - - return map(attach_socket, ('stdin', 'stdout', 'stderr')) - - - def resize(self, size=None): - """ - Resize the container's PTY. - - If `size` is not None, it must be a tuple of (height,width), otherwise - it will be determined by the size of the current TTY. - """ - - if not self.israw(): - return - - size = size or tty.size(sys.stdout) - - if size is not None: - rows, cols = size - try: - self.client.resize(self.container, height=rows, width=cols) - except IOError: # Container already exited - pass - - - def container_info(self): - """ - Thin wrapper around client.inspect_container(). - """ - - return self.client.inspect_container(self.container) - - - def _hijack_tty(self, pumps): - with tty.Terminal(sys.stdin, raw=self.israw()): - self.resize() - while True: - ready = io.select(pumps, timeout=60) - try: - if any([p.flush() is None for p in ready]): - break - except SSLError as e: - if 'The operation did not complete' not in e.strerror: - raise e diff --git a/debian/bundle/dockerpty-0.3.2/dockerpty/tty.py b/debian/bundle/dockerpty-0.3.2/dockerpty/tty.py deleted file mode 100644 index bd2ccb5a..00000000 --- a/debian/bundle/dockerpty-0.3.2/dockerpty/tty.py +++ /dev/null @@ -1,130 +0,0 @@ -# dockerpty: tty.py -# -# Copyright 2014 Chris Corbyn <chris@w3style.co.uk> -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from __future__ import absolute_import - -import os -import termios -import tty -import fcntl -import struct - - -def size(fd): - """ - Return a tuple (rows,cols) representing the size of the TTY `fd`. - - The provided file descriptor should be the stdout stream of the TTY. - - If the TTY size cannot be determined, returns None. - """ - - if not os.isatty(fd.fileno()): - return None - - try: - dims = struct.unpack('hh', fcntl.ioctl(fd, termios.TIOCGWINSZ, 'hhhh')) - except: - try: - dims = (os.environ['LINES'], os.environ['COLUMNS']) - except: - return None - - return dims - - -class Terminal(object): - """ - Terminal provides wrapper functionality to temporarily make the tty raw. - - This is useful when streaming data from a pseudo-terminal into the tty. - - Example: - - with Terminal(sys.stdin, raw=True): - do_things_in_raw_mode() - """ - - def __init__(self, fd, raw=True): - """ - Initialize a terminal for the tty with stdin attached to `fd`. - - Initializing the Terminal has no immediate side effects. The `start()` - method must be invoked, or `with raw_terminal:` used before the - terminal is affected. - """ - - self.fd = fd - self.raw = raw - self.original_attributes = None - - - def __enter__(self): - """ - Invoked when a `with` block is first entered. - """ - - self.start() - return self - - - def __exit__(self, *_): - """ - Invoked when a `with` block is finished. - """ - - self.stop() - - - def israw(self): - """ - Returns True if the TTY should operate in raw mode. - """ - - return self.raw - - - def start(self): - """ - Saves the current terminal attributes and makes the tty raw. - - This method returns None immediately. - """ - - if os.isatty(self.fd.fileno()) and self.israw(): - self.original_attributes = termios.tcgetattr(self.fd) - tty.setraw(self.fd) - - - def stop(self): - """ - Restores the terminal attributes back to before setting raw mode. - - If the raw terminal was not started, does nothing. - """ - - if self.original_attributes is not None: - termios.tcsetattr( - self.fd, - termios.TCSADRAIN, - self.original_attributes, - ) - - def __repr__(self): - return "{cls}({fd}, raw={raw})".format( - cls=type(self).__name__, - fd=self.fd, - raw=self.raw) diff --git a/debian/bundle/dockerpty-0.3.2/features/environment.py b/debian/bundle/dockerpty-0.3.2/features/environment.py deleted file mode 100644 index e75b62fb..00000000 --- a/debian/bundle/dockerpty-0.3.2/features/environment.py +++ /dev/null @@ -1,38 +0,0 @@ -# dockerpty: environment.py -# -# Copyright 2014 Chris Corbyn <chris@w3style.co.uk> -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import docker - - -def before_all(ctx): - """ - Pulls down busybox:latest before anything is tested. - """ - - ctx.client = docker.Client() - ctx.client.pull('busybox:latest') - - -def after_scenario(ctx, scenario): - """ - Cleans up docker containers used as test fixtures after test completes. - """ - - if hasattr(ctx, 'container') and hasattr(ctx, 'client'): - try: - ctx.client.remove_container(ctx.container, force=True) - except: - pass diff --git a/debian/bundle/dockerpty-0.3.2/features/interactive_stdin.feature b/debian/bundle/dockerpty-0.3.2/features/interactive_stdin.feature deleted file mode 100644 index cc40cfc0..00000000 --- a/debian/bundle/dockerpty-0.3.2/features/interactive_stdin.feature +++ /dev/null @@ -1,106 +0,0 @@ -# dockerpty: interactive_stdin.feature. -# -# Copyright 2014 Chris Corbyn <chris@w3style.co.uk> -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -Feature: Attaching to a docker container with stdin open - As a user I want to be able to attach to a process in a running docker - and send it data via stdin. - - - Scenario: Capturing output - Given I am using a TTY - And I run "tail -f /etc/issue" in a docker container with stdin open - When I start dockerpty - Then I will see the output - """ - Welcome to Buildroot - """ - - - Scenario: Sending input - Given I am using a TTY - And I run "/bin/cat" in a docker container with stdin open - When I start dockerpty - And I type "Hello World!" - And I press ENTER - Then I will see the output - """ - Hello World! - Hello World! - """ - - - Scenario: Capturing errors - Given I am using a TTY - And I run "sh -c 'cat | sh'" in a docker container with stdin open - When I start dockerpty - And I type "echo 'Hello World!' 1>&2" - And I press ENTER - Then I will see the output - """ - echo 'Hello World!' 1>&2 - Hello World! - """ - - - Scenario: Capturing mixed output and errors - Given I am using a TTY - And I run "sh -c 'cat | sh'" in a docker container with stdin open - When I start dockerpty - And I type "echo 'Hello World!'" - And I press ENTER - Then I will see the output - """ - echo 'Hello World!' - Hello World! - """ - When I type "echo 'Hello Universe!' 1>&2" - And I press ENTER - Then I will see the output - """ - echo 'Hello Universe!' 1>&2 - Hello Universe! - """ - - - Scenario: Closing input - Given I am using a TTY - And I run "/bin/cat" in a docker container with stdin open - When I start dockerpty - And I type "Hello World!" - And I press ENTER - Then I will see the output - """ - Hello World! - Hello World! - """ - When I press C-d - Then The PTY will be closed cleanly - And The container will not be running - - - Scenario: Running when the container is started - Given I am using a TTY - And I run "/bin/cat" in a docker container with stdin open - When I start the container - And I start dockerpty - And I type "Hello World!" - And I press ENTER - Then I will see the output - """ - Hello World! - Hello World! - """ diff --git a/debian/bundle/dockerpty-0.3.2/features/interactive_terminal.feature b/debian/bundle/dockerpty-0.3.2/features/interactive_terminal.feature deleted file mode 100644 index edf77f14..00000000 --- a/debian/bundle/dockerpty-0.3.2/features/interactive_terminal.feature +++ /dev/null @@ -1,178 +0,0 @@ -# dockerpty: interactive_terminal.feature. -# -# Copyright 2014 Chris Corbyn <chris@w3style.co.uk> -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -Feature: Attaching to an interactive terminal in a docker container - As a user I want to be able to attach to a shell in a running docker - container and control inside my own terminal. - - - Scenario: Starting the PTY - Given I am using a TTY - And I run "/bin/sh" in a docker container with a PTY - When I start dockerpty - Then I will see the output - """ - / # - """ - - - Scenario: Controlling input - Given I am using a TTY - And I run "/bin/sh" in a docker container with a PTY - When I start dockerpty - And I type "whoami" - Then I will see the output - """ - / # whoami - """ - - - Scenario: Controlling standard output - Given I am using a TTY - And I run "/bin/sh" in a docker container with a PTY - When I start dockerpty - And I type "uname" - And I press ENTER - Then I will see the output - """ - / # uname - Linux - / # - """ - - - Scenario: Controlling standard error - Given I am using a TTY - And I run "/bin/sh" in a docker container with a PTY - When I start dockerpty - And I type "ls blah" - And I press ENTER - Then I will see the output - """ - / # ls blah - ls: blah: No such file or directory - / # - """ - - - Scenario: Initializing the PTY with the correct size - Given I am using a TTY with dimensions 20 x 70 - And I run "/bin/sh" in a docker container with a PTY - When I start dockerpty - And I type "stty size" - And I press ENTER - Then I will see the output - """ - / # stty size - 20 70 - / # - """ - - - Scenario: Resizing the PTY - Given I am using a TTY with dimensions 20 x 70 - And I run "/bin/sh" in a docker container with a PTY - When I start dockerpty - And I resize the terminal to 30 x 100 - And I type "stty size" - And I press ENTER - Then I will see the output - """ - / # stty size - 30 100 - / # - """ - - - Scenario: Resizing the PTY frenetically - Given I am using a TTY with dimensions 20 x 70 - And I run "/bin/sh" in a docker container with a PTY - When I start dockerpty - And I resize the terminal to 30 x 100 - And I resize the terminal to 30 x 101 - And I resize the terminal to 30 x 98 - And I resize the terminal to 28 x 98 - And I resize the terminal to 28 x 105 - And I type "stty size" - And I press ENTER - Then I will see the output - """ - / # stty size - 28 105 - / # - """ - - - Scenario: Terminating the PTY - Given I am using a TTY - And I run "/bin/sh" in a docker container with a PTY - When I start dockerpty - And I type "exit" - And I press ENTER - Then The PTY will be closed cleanly - And The container will not be running - - - Scenario: Detaching from the PTY - Given I am using a TTY - And I run "/bin/sh" in a docker container with a PTY - When I start dockerpty - And I press ENTER - And I press C-p - And I press C-q - Then The PTY will be closed cleanly - And The container will still be running - - - Scenario: Reattaching to the PTY - Given I am using a TTY - And I run "/bin/sh" in a docker container with a PTY - When I start dockerpty - And I type "uname" - And I press ENTER - And I press C-p - And I press C-q - Then The PTY will be closed cleanly - When I start dockerpty - And I press ENTER - And I press UP - And I press ENTER - Then I will see the output - """ - / # uname - Linux - / # - """ - - - Scenario: Cleanly exiting on race conditions - Given I am using a TTY - And I run "/bin/true" in a docker container with a PTY - When I start dockerpty - Then The PTY will be closed cleanly - - - Scenario: Running when the container is started - Given I am using a TTY - And I run "/bin/sh" in a docker container with a PTY - When I start the container - And I start dockerpty - And I press ENTER - Then I will see the output - """ - / # - """ diff --git a/debian/bundle/dockerpty-0.3.2/features/non_interactive.feature b/debian/bundle/dockerpty-0.3.2/features/non_interactive.feature deleted file mode 100644 index 1a151139..00000000 --- a/debian/bundle/dockerpty-0.3.2/features/non_interactive.feature +++ /dev/null @@ -1,63 +0,0 @@ -# dockerpty: non_interactive.feature. -# -# Copyright 2014 Chris Corbyn <chris@w3style.co.uk> -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -Feature: Attaching to a docker container non-interactively - As a user I want to be able to attach to a process in a running docker - container and view its output in my own terminal. - - - Scenario: Capturing output - Given I am using a TTY - And I run "/usr/bin/tail -f /etc/issue" in a docker container - When I start dockerpty - Then I will see the output - """ - Welcome to Buildroot - """ - - - Scenario: Capturing errors - Given I am using a TTY - And I run "sh -c 'tail -f /etc/issue 1>&2'" in a docker container - When I start dockerpty - Then I will see the output - """ - Welcome to Buildroot - """ - - - Scenario: Ignoring input - Given I am using a TTY - And I run "/usr/bin/tail -f /etc/issue" in a docker container - When I start dockerpty - And I press ENTER - Then I will see the output - """ - Welcome to Buildroot - """ - And The container will still be running - - - Scenario: Running when the container is started - Given I am using a TTY - And I run "/bin/watch -n5 cat /etc/issue" in a docker container - When I start the container - And I start dockerpty - Then I will see the output - """ - Welcome to Buildroot - """ diff --git a/debian/bundle/dockerpty-0.3.2/features/steps/step_definitions.py b/debian/bundle/dockerpty-0.3.2/features/steps/step_definitions.py deleted file mode 100644 index b630af0c..00000000 --- a/debian/bundle/dockerpty-0.3.2/features/steps/step_definitions.py +++ /dev/null @@ -1,157 +0,0 @@ -# dockerpty: step_definitions.py -# -# Copyright 2014 Chris Corbyn <chris@w3style.co.uk> -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from behave import * -from expects import expect, equal, be_true, be_false -import tests.util as util - -import dockerpty -import pty -import sys -import os -import signal -import errno -import time - - -@given('I am using a TTY') -def step_impl(ctx): - ctx.rows = 20 - ctx.cols = 80 - - -@given('I am using a TTY with dimensions {rows} x {cols}') -def step_impl(ctx, rows, cols): - ctx.rows = int(rows) - ctx.cols = int(cols) - - -@given('I run "{cmd}" in a docker container with a PTY') -def step_impl(ctx, cmd): - ctx.container = ctx.client.create_container( - image='busybox:latest', - command=cmd, - stdin_open=True, - tty=True, - ) - - -@given('I run "{cmd}" in a docker container') -def step_impl(ctx, cmd): - ctx.container = ctx.client.create_container( - image='busybox:latest', - command=cmd, - ) - - -@given('I run "{cmd}" in a docker container with stdin open') -def step_impl(ctx, cmd): - ctx.container = ctx.client.create_container( - image='busybox:latest', - command=cmd, - stdin_open=True, - ) - - -@when('I start the container') -def step_impl(ctx): - ctx.client.start(ctx.container) - - -@when('I start dockerpty') -def step_impl(ctx): - pid, fd = pty.fork() - - if pid == pty.CHILD: - tty = os.ttyname(0) - sys.stdin = open(tty, 'r') - sys.stdout = open(tty, 'w') - sys.stderr = open(tty, 'w') - - try: - dockerpty.start(ctx.client, ctx.container) - except Exception as e: - raise e - os._exit(1) - else: - os._exit(0) - else: - tty = os.ttyname(fd) - ctx.pty = fd - util.set_pty_size( - ctx.pty, - (ctx.rows, ctx.cols) - ) - ctx.pid = pid - util.wait(ctx.pty, timeout=5) - - -@when('I resize the terminal to {rows} x {cols}') -def step_impl(ctx, rows, cols): - ctx.rows = int(rows) - ctx.cols = int(cols) - util.set_pty_size( - ctx.pty, - (ctx.rows, ctx.cols) - ) - time.sleep(0.2) - os.kill(ctx.pid, signal.SIGWINCH) - - -@when('I type "{text}"') -def step_impl(ctx, text): - util.write(ctx.pty, text) - - -@when('I press {key}') -def step_impl(ctx, key): - mappings = { - "enter": "\x0a", - "up": "\x1b[A", - "down": "\x1b[B", - "right": "\x1b[C", - "left": "\x1b[D", - "esc": "\x1b", - "c-c": "\x03", - "c-d": "\x04", - "c-p": "\x10", - "c-q": "\x11", - } - util.write(ctx.pty, mappings[key.lower()]) - - -@then('I will see the output') -def step_impl(ctx): - actual = util.read_printable(ctx.pty).splitlines() - wanted = ctx.text.splitlines() - expect(actual[-len(wanted):]).to(equal(wanted)) - - -@then('The PTY will be closed cleanly') -def step_impl(ctx): - expect(util.exit_code(ctx.pid, timeout=5)).to(equal(0)) - - -@then('The container will not be running') -def step_impl(ctx): - running = util.container_running(ctx.client, ctx.container, duration=2) - expect(running).to(be_false) - - -@then('The container will still be running') -def step_impl(ctx): - running = util.container_running(ctx.client, ctx.container, duration=2) - expect(running).to(be_true) diff --git a/debian/bundle/dockerpty-0.3.2/requirements-dev.txt b/debian/bundle/dockerpty-0.3.2/requirements-dev.txt deleted file mode 100644 index 78fe60c3..00000000 --- a/debian/bundle/dockerpty-0.3.2/requirements-dev.txt +++ /dev/null @@ -1,4 +0,0 @@ -docker-py>=0.3.2 -pytest>=2.5.2 -behave>=1.2.4 -expects>=0.4 diff --git a/debian/bundle/dockerpty-0.3.2/setup.py b/debian/bundle/dockerpty-0.3.2/setup.py deleted file mode 100644 index 2b7165d4..00000000 --- a/debian/bundle/dockerpty-0.3.2/setup.py +++ /dev/null @@ -1,48 +0,0 @@ -# dockerpty. -# -# Copyright 2014 Chris Corbyn <chris@w3style.co.uk> -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from setuptools import setup -import os - -def fopen(filename): - return open(os.path.join(os.path.dirname(__file__), filename)) - -def read(filename): - return fopen(filename).read() - -setup( - name='dockerpty', - version='0.3.2', - description='Python library to use the pseudo-tty of a docker container', - long_description=read('README.md'), - url='https://github.com/d11wtq/dockerpty', - author='Chris Corbyn', - author_email='chris@w3style.co.uk', - license='Apache 2.0', - keywords='docker, tty, pty, terminal', - packages=['dockerpty'], - classifiers=[ - 'Development Status :: 4 - Beta', - 'License :: OSI Approved :: Apache Software License', - 'Programming Language :: Python', - 'Environment :: Console', - 'Intended Audience :: Developers', - 'Topic :: Terminals', - 'Topic :: Terminals :: Terminal Emulators/X Terminals', - 'Topic :: Software Development :: Libraries', - 'Topic :: Software Development :: Libraries :: Python Modules', - ], -) diff --git a/debian/bundle/dockerpty-0.3.2/tests/__init__.py b/debian/bundle/dockerpty-0.3.2/tests/__init__.py deleted file mode 100644 index e69de29b..00000000 --- a/debian/bundle/dockerpty-0.3.2/tests/__init__.py +++ /dev/null diff --git a/debian/bundle/dockerpty-0.3.2/tests/unit/__init__.py b/debian/bundle/dockerpty-0.3.2/tests/unit/__init__.py deleted file mode 100644 index e69de29b..00000000 --- a/debian/bundle/dockerpty-0.3.2/tests/unit/__init__.py +++ /dev/null diff --git a/debian/bundle/dockerpty-0.3.2/tests/unit/test_io.py b/debian/bundle/dockerpty-0.3.2/tests/unit/test_io.py deleted file mode 100644 index 4b23ec33..00000000 --- a/debian/bundle/dockerpty-0.3.2/tests/unit/test_io.py +++ /dev/null @@ -1,195 +0,0 @@ -# dockerpty: test_io.py. -# -# Copyright 2014 Chris Corbyn <chris@w3style.co.uk> -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from expects import expect, equal, be_none, be_true, be_false -from io import StringIO -import dockerpty.io as io - -import sys -import os -import fcntl -import socket -import tempfile - - -def test_set_blocking_changes_fd_flags(): - with tempfile.TemporaryFile() as f: - io.set_blocking(f, False) - flags = fcntl.fcntl(f, fcntl.F_GETFL) - expect(flags & os.O_NONBLOCK).to(equal(os.O_NONBLOCK)) - - io.set_blocking(f, True) - flags = fcntl.fcntl(f, fcntl.F_GETFL) - expect(flags & os.O_NONBLOCK).to(equal(0)) - - -def test_set_blocking_returns_previous_state(): - with tempfile.TemporaryFile() as f: - io.set_blocking(f, True) - expect(io.set_blocking(f, False)).to(be_true) - - io.set_blocking(f, False) - expect(io.set_blocking(f, True)).to(be_false) - - -def test_select_returns_streams_for_reading(): - a, b = socket.socketpair() - a.send('test') - expect(io.select([a, b], timeout=0)).to(equal([b])) - b.send('test') - expect(io.select([a, b], timeout=0)).to(equal([a, b])) - b.recv(4) - expect(io.select([a, b], timeout=0)).to(equal([a])) - a.recv(4) - expect(io.select([a, b], timeout=0)).to(equal([])) - - -class TestStream(object): - - def test_fileno_delegates_to_file_descriptor(self): - stream = io.Stream(sys.stdout) - expect(stream.fileno()).to(equal(sys.stdout.fileno())) - - - def test_read_from_socket(self): - a, b = socket.socketpair() - a.send('test') - stream = io.Stream(b) - expect(stream.read(32)).to(equal('test')) - - - def test_write_to_socket(self): - a, b = socket.socketpair() - stream = io.Stream(a) - stream.write('test') - expect(b.recv(32)).to(equal('test')) - - - def test_read_from_file(self): - with tempfile.TemporaryFile() as f: - stream = io.Stream(f) - f.write('test') - f.seek(0) - expect(stream.read(32)).to(equal('test')) - - - def test_read_returns_empty_string_at_eof(self): - with tempfile.TemporaryFile() as f: - stream = io.Stream(f) - expect(stream.read(32)).to(equal('')) - - - def test_write_to_file(self): - with tempfile.TemporaryFile() as f: - stream = io.Stream(f) - stream.write('test') - f.seek(0) - expect(f.read(32)).to(equal('test')) - - - def test_write_returns_length_written(self): - with tempfile.TemporaryFile() as f: - stream = io.Stream(f) - expect(stream.write('test')).to(equal(4)) - - - def test_write_returns_none_when_no_data(self): - stream = io.Stream(StringIO()) - expect(stream.write('')).to(be_none) - - def test_repr(self): - fd = StringIO() - stream = io.Stream(fd) - expect(repr(stream)).to(equal("Stream(%s)" % fd)) - - -class TestDemuxer(object): - - def create_fixture(self): - chunks = [ - "\x01\x00\x00\x00\x00\x00\x00\x03foo", - "\x01\x00\x00\x00\x00\x00\x00\x01d", - ] - return StringIO(u''.join(chunks)) - - - def test_fileno_delegates_to_stream(self): - demuxer = io.Demuxer(sys.stdout) - expect(demuxer.fileno()).to(equal(sys.stdout.fileno())) - - - def test_reading_single_chunk(self): - demuxer = io.Demuxer(self.create_fixture()) - expect(demuxer.read(32)).to(equal('foo')) - - - def test_reading_multiple_chunks(self): - demuxer = io.Demuxer(self.create_fixture()) - expect(demuxer.read(32)).to(equal('foo')) - expect(demuxer.read(32)).to(equal('d')) - - - def test_reading_partial_chunk(self): - demuxer = io.Demuxer(self.create_fixture()) - expect(demuxer.read(2)).to(equal('fo')) - - - def test_reading_overlapping_chunks(self): - demuxer = io.Demuxer(self.create_fixture()) - expect(demuxer.read(2)).to(equal('fo')) - expect(demuxer.read(2)).to(equal('o')) - expect(demuxer.read(2)).to(equal('d')) - - - def test_write_delegates_to_stream(self): - s = StringIO() - demuxer = io.Demuxer(s) - demuxer.write(u'test') - expect(s.getvalue()).to(equal('test')) - - def test_repr(self): - s = StringIO() - demuxer = io.Demuxer(s) - expect(repr(demuxer)).to(equal("Demuxer(%s)" % s)) - - -class TestPump(object): - - def test_fileno_delegates_to_from_stream(self): - pump = io.Pump(sys.stdout, sys.stderr) - expect(pump.fileno()).to(equal(sys.stdout.fileno())) - - - def test_flush_pipes_data_between_streams(self): - a = StringIO(u'food') - b = StringIO() - pump = io.Pump(a, b) - pump.flush(3) - expect(a.read(1)).to(equal('d')) - expect(b.getvalue()).to(equal('foo')) - - - def test_flush_returns_length_written(self): - a = StringIO(u'fo') - b = StringIO() - pump = io.Pump(a, b) - expect(pump.flush(3)).to(equal(2)) - - def test_repr(self): - a = StringIO(u'fo') - b = StringIO() - pump = io.Pump(a, b) - expect(repr(pump)).to(equal("Pump(from=%s, to=%s)" % (a, b))) diff --git a/debian/bundle/dockerpty-0.3.2/tests/unit/test_tty.py b/debian/bundle/dockerpty-0.3.2/tests/unit/test_tty.py deleted file mode 100644 index d9a4832a..00000000 --- a/debian/bundle/dockerpty-0.3.2/tests/unit/test_tty.py +++ /dev/null @@ -1,85 +0,0 @@ -# dockerpty: test_tty.py. -# -# Copyright 2014 Chris Corbyn <chris@w3style.co.uk> -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from expects import expect, equal, be_none, be_true, be_false -import dockerpty.tty as tty -import tests.util as util - -import os -import pty -import termios -import tempfile - - -def israw(fd): - __, __, __, flags, __, __, __ = termios.tcgetattr(fd) - return not flags & termios.ECHO - - -def test_size_returns_none_for_non_tty(): - with tempfile.TemporaryFile() as t: - expect(tty.size(t)).to(be_none) - - -def test_size_returns_a_tuple_for_a_tty(): - fd, __ = pty.openpty() - fd = os.fdopen(fd) - util.set_pty_size(fd, (43, 120)) - expect(tty.size(fd)).to(equal((43, 120))) - - -class TestTerminal(object): - - def test_start_when_raw(self): - fd, __ = pty.openpty() - terminal = tty.Terminal(os.fdopen(fd), raw=True) - expect(israw(fd)).to(be_false) - terminal.start() - expect(israw(fd)).to(be_true) - - def test_start_when_not_raw(self): - fd, __ = pty.openpty() - terminal = tty.Terminal(os.fdopen(fd), raw=False) - expect(israw(fd)).to(be_false) - terminal.start() - expect(israw(fd)).to(be_false) - - def test_stop_when_raw(self): - fd, __ = pty.openpty() - terminal = tty.Terminal(os.fdopen(fd), raw=True) - terminal.start() - terminal.stop() - expect(israw(fd)).to(be_false) - - def test_raw_with_block(self): - fd, __ = pty.openpty() - fd = os.fdopen(fd) - - with tty.Terminal(fd, raw=True): - expect(israw(fd)).to(be_true) - - expect(israw(fd)).to(be_false) - - def test_start_does_not_crash_when_fd_is_not_a_tty(self): - with tempfile.TemporaryFile() as f: - terminal = tty.Terminal(f, raw=True) - terminal.start() - terminal.stop() - - def test_repr(self): - fd = 'some_fd' - terminal = tty.Terminal(fd, raw=True) - expect(repr(terminal)).to(equal("Terminal(some_fd, raw=True)")) diff --git a/debian/bundle/dockerpty-0.3.2/tests/util.py b/debian/bundle/dockerpty-0.3.2/tests/util.py deleted file mode 100644 index c7356fc7..00000000 --- a/debian/bundle/dockerpty-0.3.2/tests/util.py +++ /dev/null @@ -1,145 +0,0 @@ -# dockerpty: util.py -# -# Copyright 2014 Chris Corbyn <chris@w3style.co.uk> -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import termios -import struct -import fcntl -import select -import os -import re -import time - - -def set_pty_size(fd, size): - """ - Resize the PTY at `fd` to (rows, cols) size. - """ - - rows, cols = size - fcntl.ioctl( - fd, - termios.TIOCSWINSZ, - struct.pack('hhhh', rows, cols, 0, 0) - ) - - -def wait(fd, timeout=2): - """ - Wait until data is ready for reading on `fd`. - """ - - return select.select([fd], [], [], timeout)[0] - - -def printable(text): - """ - Convert text to only printable characters, as a user would see it. - """ - - ansi = re.compile(r'\x1b\[[^Jm]*[Jm]') - return ansi.sub('', text).rstrip() - - -def write(fd, data): - """ - Write `data` to the PTY at `fd`. - """ - - os.write(fd, data) - - -def readchar(fd): - """ - Read a character from the PTY at `fd`, or nothing if no data to read. - """ - - while True: - ready = wait(fd) - if len(ready) == 0: - return '' - else: - for s in ready: - return os.read(s, 1) - - -def readline(fd): - """ - Read a line from the PTY at `fd`, or nothing if no data to read. - - The line includes the line ending. - """ - - output = [] - while True: - char = readchar(fd) - if char: - output.append(char) - if char == "\n": - return ''.join(output) - else: - return ''.join(output) - - -def read(fd): - """ - Read all output from the PTY at `fd`, or nothing if no data to read. - """ - - output = [] - while True: - line = readline(fd) - if line: - output.append(line) - else: - return "".join(output) - - -def read_printable(fd): - """ - Read all output from the PTY at `fd` as a user would see it. - - Warning: This is not exhaustive; it won't render Vim, for example. - """ - - lines = read(fd).splitlines() - return "\n".join([printable(line) for line in lines]).lstrip("\r\n") - - -def exit_code(pid, timeout=5): - """ - Wait up to `timeout` seconds for `pid` to exit and return its exit code. - - Returns -1 if the `pid` does not exit. - """ - - start = time.time() - while True: - _, status = os.waitpid(pid, os.WNOHANG) - if os.WIFEXITED(status): - return os.WEXITSTATUS(status) - else: - if (time.time() - start) > timeout: - return -1 - - -def container_running(client, container, duration=2): - """ - Predicate to check if a container continues to run after `duration` secs. - """ - - time.sleep(duration) - config = client.inspect_container(container) - return config['State']['Running'] diff --git a/debian/bundle/dockerpty-0.3.2/tox.ini b/debian/bundle/dockerpty-0.3.2/tox.ini deleted file mode 100644 index 71470971..00000000 --- a/debian/bundle/dockerpty-0.3.2/tox.ini +++ /dev/null @@ -1,9 +0,0 @@ -[tox] -envlist = py27, pypy - -[testenv] -deps = - -rrequirements-dev.txt -commands = - py.test -v tests/ - behave diff --git a/debian/copyright b/debian/copyright index 308705f6..6fc47f56 100644 --- a/debian/copyright +++ b/debian/copyright @@ -6,7 +6,7 @@ Files: * Copyright: 2014 Docker Inc License: Apache-2.0 -Files: debian/bundle/dockerpty*/* +Files: fig/packages/dockerpty/* Copyright: 2014 Chris Corbyn <chris@w3style.co.uk> License: Apache-2.0 diff --git a/debian/patches/Use-bundled-version-of-dockerpty.patch b/debian/patches/Use-bundled-version-of-dockerpty.patch deleted file mode 100644 index 5032f6c2..00000000 --- a/debian/patches/Use-bundled-version-of-dockerpty.patch +++ /dev/null @@ -1,46 +0,0 @@ -From: Felipe Sateler <fsateler@debian.org> -Date: Fri, 27 Mar 2015 19:32:03 -0300 -Subject: Use bundled version of dockerpty - ---- - compose/cli/main.py | 2 +- - requirements.txt | 1 - - setup.py | 1 - - 3 files changed, 1 insertion(+), 3 deletions(-) - -diff --git a/compose/cli/main.py b/compose/cli/main.py -index cfe29cd..d6ac508 100644 ---- a/compose/cli/main.py -+++ b/compose/cli/main.py -@@ -7,7 +7,7 @@ import signal - from operator import attrgetter - - from inspect import getdoc --import dockerpty -+from .. import dockerpty - - from .. import __version__ - from ..project import NoSuchService, ConfigurationError -diff --git a/requirements.txt b/requirements.txt -index a31a19a..881144c 100644 ---- a/requirements.txt -+++ b/requirements.txt -@@ -1,6 +1,5 @@ - PyYAML==3.10 - docker-py==0.7.1 --dockerpty==0.3.2 - docopt==0.6.1 - requests==2.2.1 - six==1.7.3 -diff --git a/setup.py b/setup.py -index 20c4330..d8b44e8 100644 ---- a/setup.py -+++ b/setup.py -@@ -31,7 +31,6 @@ install_requires = [ - 'texttable >= 0.8.1, < 0.9', - 'websocket-client >= 0.11.0, < 1.0', - 'docker-py >= 0.6.0, < 0.8', -- 'dockerpty >= 0.3.2, < 0.4', - 'six >= 1.3.0, < 2', - ] - diff --git a/debian/patches/series b/debian/patches/series index 1b564dea..d2a27cc6 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,2 +1 @@ Drop-pyinstaller-requirement.patch -Use-bundled-version-of-dockerpty.patch diff --git a/debian/rules b/debian/rules index cd1c2326..a6ba5374 100755 --- a/debian/rules +++ b/debian/rules @@ -4,11 +4,6 @@ export PYBUILD_NAME=docker-compose %: dh $@ --with python2 --buildsystem=pybuild -override_dh_auto_install: - install -d $(CURDIR)/debian/bundle/dockerpty-0.3.2 \ - $(CURDIR)/debian/usr/lib/python2.7/dist-packages/compose/dockerpty - dh_auto_install --buildsystem=pybuild - override_dh_auto_test: # tests disabled because they require networking |