@@ -41,18 +41,15 @@ ssh_controller.connect()
41
41
42
42
#### 3. Run a command
43
43
``` python
44
- return_code , output = ssh_controller.run(
44
+ exit_code , output = ssh_controller.run(
45
45
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
54
51
)
55
- print (f " return code: { return_code } , output: { output} " )
52
+ print (f " exit code: { exit_code } , output: { output} " )
56
53
```
57
54
58
55
#### 4. Transfer data with SFTP
@@ -98,13 +95,13 @@ ssh_controller.connect()
98
95
```
99
96
100
97
#### 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.
104
101
105
102
The 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.
108
105
109
106
``` python
110
107
import logging
@@ -153,8 +150,8 @@ finally:
153
150
stop_event_ping.set()
154
151
time.sleep(2 )
155
152
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 } " )
158
155
logging.info(f " thread ping output length: { len (ping_output)} " )
159
156
160
157
ssh_controller.disconnect()
0 commit comments