1616# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1717
1818
19- """Package containing ParallelSSHClient class. """
19+ """Package containing ParallelSSHClient class"""
2020
2121import sys
2222if 'threading' in sys .modules :
@@ -139,19 +139,23 @@ def __init__(self, hosts,
139139 .. code-block:: python
140140
141141 pprint(output)
142-
143- {'myhost1': {'exit_code': None,
144- 'stdout' : <generator>,
145- 'stderr' : <generator>,
146- 'cmd' : <greenlet>,
147- 'exception' : None,
148- },
149- 'myhost2': {'exit_code': None,
150- 'stdout' : <generator>,
151- 'stderr' : <generator>,
152- 'cmd' : <greenlet>,
153- 'exception' : None,
154- }}
142+ {'myhost1':
143+ host=myhost1
144+ cmd=<Greenlet>
145+ channel=<channel>
146+ stdout=<generator>
147+ stderr=<generator>
148+ stdin=<channel>
149+ exception=None
150+ 'myhost2':
151+ host=myhost2
152+ cmd=<Greenlet>
153+ channel=<channel>
154+ stdout=<generator>
155+ stderr=<generator>
156+ stdin=<channel>
157+ exception=None
158+ }
155159
156160 **Enabling host logger**
157161
@@ -378,8 +382,9 @@ def run_command(self, *args, **kwargs):
378382 host list - :py:class:`pssh.exceptions.HostArgumentException` is raised \
379383 otherwise
380384 :type host_args: tuple or list
381- :rtype: Dictionary with host as key as per \
382- :py:func:`pssh.pssh_client.ParallelSSHClient.get_output`
385+ :rtype: Dictionary with host as key and \
386+ :py:class:`pssh.output.HostOutput` as value as per \
387+ :py:func:`pssh.pssh_client.ParallelSSHClient.get_output`
383388
384389 :raises: :py:class:`pssh.exceptions.AuthenticationException` on \
385390 authentication error
@@ -528,13 +533,14 @@ def run_command(self, *args, **kwargs):
528533
529534 client.hosts = ['otherhost']
530535 print(client.run_command('exit 0'))
531- {'otherhost': {' exit_code': None} , <..>}
536+ {'otherhost': exit_code= None, <..>}
532537
533538 **Run multiple commands in parallel**
534539
535- This short example demonstrates running long running commands in
536- parallel, how long it takes for all commands to start, blocking until
537- they complete and how long it takes for all commands to complete.
540+ This short example demonstrates running multiple long running commands
541+ in parallel on the same host, how long it takes for all commands to
542+ start, blocking until they complete and how long it takes for all
543+ commands to complete.
538544
539545 See examples directory for complete script. ::
540546
@@ -562,7 +568,7 @@ def run_command(self, *args, **kwargs):
562568 Started 10 commands in 0:00:00.428629
563569 All commands finished in 0:00:05.014757
564570
565- *Output dictionary *
571+ *Output format *
566572
567573 ::
568574
@@ -668,7 +674,8 @@ def get_output(self, cmd, output):
668674
669675 :param cmd: Command to get output from
670676 :type cmd: :py:class:`gevent.Greenlet`
671- :param output: Dictionary containing output to be updated with output \
677+ :param output: Dictionary containing \
678+ :py:class:`pssh.output.HostOutput` values to be updated with output \
672679 from cmd
673680 :type output: dict
674681 :rtype: None
@@ -677,12 +684,14 @@ def get_output(self, cmd, output):
677684
678685 ::
679686
680- {'myhost1': {'exit_code': exit code if ready else None,
681- 'channel' : SSH channel of command,
682- 'stdout' : <iterable>,
683- 'stderr' : <iterable>,
684- 'cmd' : <greenlet>,
685- 'exception' : <exception object if applicable>}}
687+ {'myhost1':
688+ exit_code=exit code if ready else None
689+ channel=SSH channel of command
690+ stdout=<iterable>
691+ stderr=<iterable>
692+ cmd=<greenlet>
693+ exception=<exception object if applicable>
694+ }
686695
687696 Stdout and stderr are also logged via the logger named ``host_logger``
688697 which can be enabled by calling ``enable_host_logger``
@@ -735,6 +744,7 @@ def _update_host_output(self, output, host, exit_code, channel, stdout,
735744 "key for %s to %s" , host , host , new_host )
736745 host = new_host
737746 output [host ] = HostOutput (host , cmd , channel , stdout , stderr , stdin ,
747+ exit_code = exit_code ,
738748 exception = exception )
739749
740750 def join (self , output ):
@@ -782,7 +792,7 @@ def get_exit_code(self, host_output):
782792
783793 def _get_exit_code (self , channel ):
784794 """Get exit code from channel if ready"""
785- if not channel or not channel .exit_status_ready ():
795+ if channel is None or not channel .exit_status_ready ():
786796 return
787797 channel .close ()
788798 return channel .recv_exit_status ()
0 commit comments