@@ -11,6 +11,17 @@ def __init__(self):
11
11
self .scp_client = None
12
12
13
13
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
+ """
14
25
try :
15
26
port = int (port )
16
27
except :
@@ -19,16 +30,37 @@ def open_connection(self, hostname, port='22', username=None, password=None):
19
30
self .scp_client = SCPClient (self .ssh .get_transport ())
20
31
21
32
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
+ """
22
40
if self .scp_client is not None :
23
41
self .scp_client .close ()
24
42
self .scp_client = None
25
43
26
44
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
+ """
27
52
if self .scp_client is None :
28
53
raise SCPNotConnectedError ("An SCPLibrary connection must be created first using the 'Open Connection' keyword." )
29
54
self .scp_client .put (local_filepath , remote_filepath )
30
55
31
56
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
+ """
32
64
if self .scp_client is None :
33
65
raise SCPNotConnectedError ("An SCPLibrary connection must be created first using the 'Open Connection' keyword." )
34
66
self .scp_client .get (remote_filepath , local_filepath )
0 commit comments