Skip to content

Commit ecc9633

Browse files
Danpkittenis
authored andcommitted
Updated documentation. Code cleanup
1 parent a7e504f commit ecc9633

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

pssh.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,9 @@ class ParallelSSHClient(object):
216216
"""Uses :mod:`pssh.SSHClient`, performs tasks over SSH on multiple hosts in \
217217
parallel.
218218
219-
Connections to hosts are established in parallel when an object of this class \
220-
is created, therefor any connection and/or authentication failures will happen \
221-
on creation and need to be caught."""
219+
Connections to hosts are established in parallel when an object of this
220+
class is created, therefor any connection and/or authentication exceptions \
221+
will happen on creation and need to be caught."""
222222

223223
def __init__(self, hosts,
224224
user=None, password=None, port=None, pkey=None,
@@ -272,12 +272,12 @@ def __init__(self, hosts,
272272
>>> cmds = client.exec_command('ls -ltrh /tmp/aasdfasdf', sudo = True)
273273
>>> output = [client.get_stdout(cmd, return_buffers=True) for cmd in cmds]
274274
>>> print output
275-
[{'myhost1': {'exit_code': 2},
275+
[{'myhost1': {'exit_code': 2,
276276
'stdout' : <generator object <genexpr>,
277-
'stderr' : <generator object <genexpr>},
278-
{'myhost2': {'exit_code': 2}
277+
'stderr' : <generator object <genexpr>,}},
278+
{'myhost2': {'exit_code': 2,
279279
'stdout' : <generator object <genexpr>,
280-
'stderr' : <generator object <genexpr>},
280+
'stderr' : <generator object <genexpr>,}},
281281
]
282282
>>> for host_stdout in output:
283283
... for line in host_stdout[host_output.keys()[0]]['stdout']:
@@ -361,7 +361,7 @@ def _exec_command(self, host, *args, **kwargs):
361361
return self.host_clients[host].exec_command(*args, **kwargs)
362362

363363
def get_stdout(self, greenlet, return_buffers=False):
364-
"""Print stdout from greenlet and return exit code for host
364+
"""Get/print stdout from greenlet and return exit code for host
365365
366366
:mod:`pssh.get_stdout` will close the open SSH channel but this does
367367
**not** close the established connection to the remote host, only the
@@ -371,8 +371,8 @@ def get_stdout(self, greenlet, return_buffers=False):
371371
connections.
372372
373373
By default, stdout and stderr will be logged via the logger named \
374-
`host_logger` unless return_buffers is set to True in which case \
375-
both buffers are returned along with the exit status.
374+
``host_logger`` unless ``return_buffers`` is set to ``True`` in which case \
375+
both buffers are instead returned along with the exit status.
376376
377377
:param greenlet: Greenlet object containing an \
378378
SSH channel reference, hostname, stdout and stderr buffers
@@ -384,9 +384,9 @@ def get_stdout(self, greenlet, return_buffers=False):
384384
385385
:rtype: Dictionary containing ``{host: {'exit_code': exit code}}`` entry \
386386
for example ``{'myhost1': {'exit_code': 0}}``
387-
:rtype: With return_buffers=True: ``{'myhost1': {'exit_code': 0},
388-
'stdout' : <iterable>,
389-
'stderr' : <iterable>}``
387+
:rtype: With ``return_buffers=True``: ``{'myhost1': {'exit_code': 0,
388+
'stdout' : <iterable>,
389+
'stderr' : <iterable>,}}``
390390
"""
391391
channel, host, _stdout, _stderr = greenlet.get()
392392
stdout = (line.strip() for line in _stdout)

tests/test_pssh_client.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,17 @@ def test_pssh_client_exec_command_get_buffers(self):
5757
stdout = list(output['127.0.0.1']['stdout'])
5858
stderr = list(output['127.0.0.1']['stderr'])
5959
self.assertEqual(expected_exit_code, exit_code,
60-
msg = "Got unexpected exit code - %s, expected %s" % (
61-
exit_code,
62-
expected_exit_code,))
60+
msg = "Got unexpected exit code - %s, expected %s" %
61+
(exit_code,
62+
expected_exit_code,))
6363
self.assertEqual(expected_stdout, stdout,
64-
msg = "Got unexpected stdout - %s, expected %s" % (
65-
stdout,
66-
expected_stdout,))
64+
msg = "Got unexpected stdout - %s, expected %s" %
65+
(stdout,
66+
expected_stdout,))
6767
self.assertEqual(expected_stderr, stderr,
68-
msg = "Got unexpected stderr - %s, expected %s" % (
69-
stderr,
70-
expected_stderr,))
68+
msg = "Got unexpected stderr - %s, expected %s" %
69+
(stderr,
70+
expected_stderr,))
7171
del client
7272
server.join()
7373

0 commit comments

Comments
 (0)