@@ -41,18 +41,15 @@ ssh_controller.connect()
4141
4242#### 3. Run a command
4343``` python
44- return_code , output = ssh_controller.run(
44+ exit_code , output = ssh_controller.run(
4545 command = " echo 'Hello world!' > /tmp/hello.txt" ,
46- display = True , # display output, false by default
47- capture = True , # save output, false by default
48- # request a shell to run the command, true by default
49- shell = True ,
50- # combine stderr into stdout when shell=False, false by default
51- combine_stderr = False ,
52- # command timeout in seconds, None (wait indefinitely) by default
53- timeout = 10 ,
46+ display = True , # display output, disabled by default
47+ capture = True , # save output, disabled by default
48+ shell = True , # request a shell to run the command, enabled by default
49+ combine_stderr = False , # combine stderr into stdout when shell=False, disabled by default
50+ timeout = 10 , # command timeout in seconds, None (wait indefinitely) by default
5451)
55- print (f " return code: { return_code } , output: { output} " )
52+ print (f " exit code: { exit_code } , output: { output} " )
5653```
5754
5855#### 4. Transfer data with SFTP
@@ -98,13 +95,13 @@ ssh_controller.connect()
9895```
9996
10097#### 7. Run a command until an event is set
101- If the argument ` stop_event ` is set when calling ` run() ` , the controller
102- ignores ` timeout ` and stops only when the given event is triggered instead.
103- This is especially useful when using threads.
98+ If the argument ` stop_event ` (a ` threading.Event ` object) is set when
99+ calling ` run() ` , the controller ignores ` timeout ` and stops when the given
100+ event is triggered instead. This is especially useful when using threads.
104101
105102The example below starts two threads with an event attached to each one:
106- one is pinging localhost, the other sleeps for 10s. When the sleeping threads
107- has finished, the events are triggered to also stop the pinging thread.
103+ one is pinging ` localhost ` , the other sleeps for 10s. When the sleeping thread
104+ has finished, events are triggered to also stop the pinging thread.
108105
109106``` python
110107import logging
@@ -153,8 +150,8 @@ finally:
153150 stop_event_ping.set()
154151 time.sleep(2 )
155152
156- return_code , ping_output = output.get()
157- logging.info(f " thread ping return code: { return_code } " )
153+ exit_code , ping_output = output.get()
154+ logging.info(f " thread ping exit code: { exit_code } " )
158155logging.info(f " thread ping output length: { len (ping_output)} " )
159156
160157ssh_controller.disconnect()
0 commit comments