Skip to content

Commit 89985ce

Browse files
authoredAug 20, 2020
Output exit code (#203)
Migrated exit code to HostOutput property. Added tests. Updated output generation for existing commands via get_last_output Updated travis cfg, osx wheels Updated changelog, readme and docs
1 parent be376f1 commit 89985ce

15 files changed

+309
-262
lines changed
 

‎.travis.yml

+30-69
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ install:
2828
script:
2929
# For testing SSH agent related functionality
3030
- eval `ssh-agent -s`
31-
- pytest --reruns 5 --cov-append --cov=pssh -s tests/test_native_tunnel.py
32-
- pytest --reruns 5 --cov-append --cov=pssh -s tests/test_native_*_client.py
33-
- pytest --reruns 5 --cov-append --cov=pssh -s tests/test_paramiko*.py
31+
- pytest --reruns 5 --cov-append --cov=pssh tests/test_native_tunnel.py
32+
- pytest --reruns 5 --cov-append --cov=pssh tests/test_native_*_client.py
33+
- pytest --reruns 5 --cov-append --cov=pssh tests/test_paramiko*.py
3434
- flake8 pssh
3535
- cd doc; make html; cd ..
3636
# Test building from source distribution
@@ -43,7 +43,34 @@ after_success:
4343
jobs:
4444
include:
4545

46+
- stage: test
47+
if: (type = push OR \
48+
(type = pull_request AND fork = true)) AND \
49+
tag IS blank
50+
51+
- &osx-wheels
52+
stage: build packages
53+
if: tag IS present
54+
os: osx
55+
osx_image: xcode11.6
56+
before_install:
57+
- sudo -H pip install twine
58+
- which twine
59+
install: skip
60+
script:
61+
- ./ci/osx-wheel.sh
62+
after_success:
63+
- if [[ ! -z "$TRAVIS_TAG" ]]; then
64+
twine upload --skip-existing -u $PYPI_U -p $PYPI_P wheels/*.whl;
65+
fi
66+
language: generic
67+
python: skip
68+
69+
- <<: *osx-wheels
70+
osx_image: xcode11.3
71+
4672
- stage: build packages
73+
if: tag IS present
4774
env:
4875
- WHEELS=1
4976
os: linux
@@ -69,69 +96,3 @@ jobs:
6996
distributions: sdist
7097
skip_upload_docs: true
7198
skip_cleanup: true
72-
73-
- &osx-wheels
74-
stage: build packages
75-
os: osx
76-
osx_image: xcode11.6
77-
env:
78-
- PYENV: 3.6.11
79-
before_install:
80-
- sudo -H pip install twine
81-
- which twine
82-
- mkdir -p wheels
83-
install: skip
84-
script:
85-
- ./ci/travis/pyenv-wheel.sh
86-
after_success:
87-
- if [[ ! -z "$TRAVIS_TAG" ]]; then
88-
twine upload --skip-existing -u $PYPI_U -p $PYPI_P wheels/*.whl;
89-
fi
90-
language: generic
91-
python: skip
92-
93-
- <<: *osx-wheels
94-
osx_image: xcode11.3
95-
env:
96-
- PYENV: 3.6.11
97-
98-
- <<: *osx-wheels
99-
osx_image: xcode11.6
100-
env:
101-
- PYENV: 3.7.8
102-
103-
- <<: *osx-wheels
104-
osx_image: xcode11.3
105-
env:
106-
- PYENV: 3.7.8
107-
108-
- <<: *osx-wheels
109-
osx_image: xcode11.3
110-
env:
111-
- PYENV: 3.8.5
112-
113-
- <<: *osx-wheels
114-
osx_image: xcode11.6
115-
env:
116-
- PYENV: 3.8.5
117-
118-
# - os: linux
119-
# stage: build packages
120-
# env:
121-
# - SYSTEM_PACKAGES=1
122-
# python: 3.6
123-
# before_install: skip
124-
# install: skip
125-
# script:
126-
# - docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
127-
# - ./ci/docker/build-packages.sh
128-
# deploy:
129-
# - provider: releases
130-
# skip_cleanup: true
131-
# api_key:
132-
# secure: hKf+D9ZWRCJWNQtlOWeFh7z1a+VSz+GK5qOY0e1+iV/PrM0f41wy2yej0bxG1zS6CQAnJBK6/gmq5uXXhQhGNQeIQs7zElyKlrijQAn5UstPPJTRIk2oywRr2b+q0k3V42tto6WbhjqPRpOQl/pNTjKJCc/UPgd6kOVZEhCfAec=
133-
# file_glob: true
134-
# file: '*.{deb,rpm}'
135-
# on:
136-
# repo: ParallelSSH/parallel-ssh
137-
# tags: true

‎Changelog.rst

+19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
Change Log
22
============
33

4+
1.11.0
5+
++++++
6+
7+
Changes
8+
-------
9+
10+
* Moved polling to gevent.select.poll to increase performance and better handle high number of sockets - #189
11+
* ``HostOutput.exit_code`` is now a dynamic property returning either ``None`` when exit code not ready or the exit code as reported by channel. ``ParallelSSHClient.get_exit_codes`` is now a no-op and scheduled to be removed.
12+
13+
Packaging
14+
---------
15+
16+
* Removed OSX Python 3.6 and 3.7 wheels. OSX wheels for brew python, currently 3.8, on OSX 10.14 and 10.15 are provided.
17+
18+
Fixes
19+
------
20+
21+
* Native client would fail on opening sockets with large file descriptor values - #189
22+
423
1.10.0
524
+++++++
625

‎README.rst

+8-3
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,13 @@ Native Code Client Features
116116
Exit codes
117117
***********
118118

119-
Once *either* standard output is iterated on *to completion*, or ``client.join(output)`` is called, exit codes become available in host output. Iteration ends *only when remote command has completed*, though it may be interrupted and resumed at any point.
119+
Once *either* standard output is iterated on *to completion*, or ``client.join(output)`` is called, exit codes become available in host output.
120+
121+
Iteration ends *only when remote command has completed*, though it may be interrupted and resumed at any point.
122+
123+
``HostOutput.exit_code`` is a dynamic property and will return ``None`` when exit code is not ready, meaning command has not finished, or channel is unavailable due to error.
124+
125+
Once all output has been gathered exit codes become available even without calling ``join``.
120126

121127
.. code-block:: python
122128
@@ -144,8 +150,7 @@ Similarly, output and exit codes are available after ``client.join`` is called:
144150
145151
output = client.run_command('exit 0')
146152
147-
# Wait for commands to complete and gather exit codes.
148-
# Output is updated in-place.
153+
# Wait for commands to complete
149154
client.join(output)
150155
pprint(output.values()[0].exit_code)
151156

‎ci/osx-wheel.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash -xe
2+
3+
pip3 install -U virtualenv
4+
python3 -m virtualenv -p "$(which python3)" venv
5+
6+
set +x
7+
source venv/bin/activate
8+
set -x
9+
10+
python -V
11+
pip3 install -U setuptools pip
12+
pip3 install -U delocate wheel
13+
python3 setup.py bdist_wheel
14+
delocate-listdeps dist/*.whl
15+
delocate-wheel -v -w wheels dist/*.whl
16+
delocate-listdeps wheels/*.whl
17+
18+
ls -l wheels/*.whl
19+
pip3 install -v wheels/*.whl
20+
pwd; mkdir -p temp; cd temp; pwd
21+
python3 -c "from pssh.clients import ParallelSSHClient"
22+
cd ..; pwd
23+
set +x
24+
deactivate
25+
set -x

‎doc/quickstart.rst

+12-2
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,26 @@ It is advised that client code uses ``return_list=True`` to avoid breaking on up
131131
Exit codes
132132
-------------
133133

134-
Exit codes are available on the host output object.
134+
Exit codes are available on the host output object as a dynamic property. Exit code will be ``None`` if not available, or the exit code as reported by channel.
135135

136-
First, ensure that all commands have finished and exit codes gathered by joining on the output object, then iterate over all host's output to print their exit codes.
136+
First, ensure that all commands have finished by either joining on the output object or gathering all output, then iterate over all host's output to print their exit codes.
137137

138138
.. code-block:: python
139139
140140
client.join(output)
141141
for host, host_output in output.items():
142142
print("Host %s exit code: %s" % (host, host_output.exit_code))
143143
144+
As of ``1.11.0``, ``client.join`` is not required as long as output has been gathered.
145+
146+
.. code-block:: python
147+
148+
for host_out in output.values():
149+
for line in host_out.stdout:
150+
print(line)
151+
print(host_out.exit_code)
152+
153+
144154
.. seealso::
145155

146156
:py:class:`pssh.output.HostOutput`

‎pssh/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
asynchronously and with minimal system load on the client host.
2222
2323
New users should start with
24-
:py:func:`pssh.pssh_client.ParallelSSHClient.run_command`
24+
:py:func:`pssh.clients.ParallelSSHClient.run_command`
2525
2626
See also :py:class:`pssh.ParallelSSHClient` and :py:class:mod:`pssh.SSHClient`
2727
for class documentation.

0 commit comments

Comments
 (0)
Failed to load comments.