Skip to content

Commit 28c9631

Browse files
committed
Add basic documentation to keywords.
1 parent 3b9a2e8 commit 28c9631

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

SCPLibrary/library.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ def __init__(self):
1111
self.scp_client = None
1212

1313
def open_connection(self, hostname, port='22', username=None, password=None):
14+
"""Opens a new SCP connection to the given host.
15+
16+
The default port used is `22`:
17+
| Open Connection | host.tylercrumpton.com |
18+
19+
A different port may be optionally given by using the `port` argument:
20+
| Open Connection | host.tylercrumpton.com | port=4242 |
21+
22+
Authentication may be done using a username and password:
23+
| Open Connection | host.tylercrumpton.com | username=tyler | password=iamateapot |
24+
"""
1425
try:
1526
port = int(port)
1627
except:
@@ -19,16 +30,37 @@ def open_connection(self, hostname, port='22', username=None, password=None):
1930
self.scp_client = SCPClient(self.ssh.get_transport())
2031

2132
def close_connection(self):
33+
"""Closes the SCP connection.
34+
35+
Example:
36+
| Open Connection | host.tylercrumpton.com | username=tyler | password=iamateapot |
37+
| Get File | tea.txt | /mytea/newtea.txt |
38+
| Close Connection |
39+
"""
2240
if self.scp_client is not None:
2341
self.scp_client.close()
2442
self.scp_client = None
2543

2644
def put_file(self, local_filepath, remote_filepath):
45+
"""Uploads a file to the remote machine from the local machine.
46+
47+
Note: A connection to the remote machine must be made first using the `Open Connection` keyword.
48+
49+
Example:
50+
| Put File | mytea.txt | /home/tyler/tea.txt
51+
"""
2752
if self.scp_client is None:
2853
raise SCPNotConnectedError("An SCPLibrary connection must be created first using the 'Open Connection' keyword.")
2954
self.scp_client.put(local_filepath, remote_filepath)
3055

3156
def get_file(self, remote_filepath, local_filepath):
57+
"""Downloads a file from the remote machine to the local machine.
58+
59+
Note: A connection to the remote machine must be made first using the `Open Connection` keyword.
60+
61+
Example:
62+
| Get File | /home/tyler/tea.txt | sametea.txt
63+
"""
3264
if self.scp_client is None:
3365
raise SCPNotConnectedError("An SCPLibrary connection must be created first using the 'Open Connection' keyword.")
3466
self.scp_client.get(remote_filepath, local_filepath)

0 commit comments

Comments
 (0)