Skip to content

Commit 12c9e69

Browse files
author
Olivier Roques
committed
Update README.md
1 parent 0e29249 commit 12c9e69

File tree

2 files changed

+23
-26
lines changed

2 files changed

+23
-26
lines changed

README.md

+14-17
Original file line numberDiff line numberDiff line change
@@ -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

105102
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.
108105

109106
```python
110107
import 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}")
158155
logging.info(f"thread ping output length: {len(ping_output)}")
159156

160157
ssh_controller.disconnect()

examples/demo.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@ def demo_key():
1919
key_path="~/.ssh/id_rsa", # if omitted, look in agent and in ~/.ssh/
2020
key_password=KEY_PWD, # optional
2121
key_type="rsa", # rsa (default), dsa, ecdsa or ed25519
22-
port=22, # 22 is the default
22+
port=22, # 22 by default
2323
)
2424

2525
ssh_controller.connect()
2626

27-
return_code, output = ssh_controller.run(
27+
exit_code, output = ssh_controller.run(
2828
command="echo 'Hello world!' > /tmp/hello.txt",
29-
display=True, # display output, false by default
30-
capture=True, # save output, false by default
31-
# request a shell to run the command, true by default
29+
display=True, # display output, disabled by default
30+
capture=True, # save output, disabled by default
31+
# request a shell to run the command, enabled by default
3232
shell=True,
33-
# combine stderr into stdout when shell=False, false by default
33+
# combine stderr into stdout when shell=False, disabled by default
3434
combine_stderr=False,
3535
# command timeout in seconds, None (wait indefinitely) by default
3636
timeout=10,
3737
)
38-
logging.info(f"return code: {return_code}, output: {output}")
38+
logging.info(f"exit code: {exit_code}, output: {output}")
3939

4040
print(f"hello.txt exists: {ssh_controller.exists('/tmp/hello.txt')}")
4141
print(f"bonjour.txt exists: {ssh_controller.exists('/tmp/bonjour.txt')}")
@@ -95,8 +95,8 @@ def wrapper(kwargs):
9595
stop_event_ping.set()
9696
time.sleep(2)
9797

98-
return_code, ping_output = output.get()
99-
logging.info(f"thread ping return code: {return_code}")
98+
exit_code, ping_output = output.get()
99+
logging.info(f"thread ping exit code: {exit_code}")
100100
logging.info(f"thread ping output length: {len(ping_output)}")
101101

102102
ssh_controller.disconnect()

0 commit comments

Comments
 (0)