¶
botcity.plugins.ftp.plugin.BotFTPPlugin
¶
__init__(self, hostname, username=None, password=None)
special
¶
Connect to an FTP server. If no username and password are passed, anonymous will be used by default.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hostname |
str |
The host used in the connection. |
required |
username |
str |
The username to login. |
None |
password |
str |
The password to login. |
None |
create_directory(self, dir_path)
¶
Create a new directory on the server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir_path |
str |
The name/path of the directory to be created. |
required |
Returns:
Type | Description |
---|---|
str |
The full path of the created directory. |
delete_file(self, file_name)
¶
Delete a file on the server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_name |
str |
The name/path of the file to be deleted. |
required |
disconnect(self)
¶
Close the connection with the server.
download_file(self, file_name, destination_folder)
¶
Download a file from the current folder using the file name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_name |
str |
The name of the file to be downloaded. |
required |
destination_folder |
str |
The path of the folder where the file will be saved. |
required |
get_current_directory(self)
¶
Get the current working directory.
Returns:
Type | Description |
---|---|
str |
The path of the current directory. |
get_files_list(self)
¶
Get the list of all file and folder names in the current working directory.
Returns:
Type | Description |
---|---|
List[str] |
The list with the name of the files. |
list_files(self)
¶
Prints the files and folders presents in the current folder.
remove_directory(self, dir_path)
¶
Remove a directory on the server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir_path |
str |
The name/path of the directory to be removed. |
required |
rename_file(self, from_name, to_name)
¶
Rename a file on the server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
from_name |
str |
The current file name/path. |
required |
to_name |
str |
The new file name/path. |
required |
set_current_directory(self, dir_path)
¶
Change to the specified directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir_path |
str |
The name/path of the directory. |
required |
upload_file(self, file_path)
¶
Upload a file to the current folder.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path |
str |
The path of the file to be uploaded. |
required |
botcity.plugins.ftp.plugin.BotSFTPPlugin
¶
__init__(self, hostname, port=22, username=None, password=None)
special
¶
Connect to an SFTP server over a SSH session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hostname |
str |
The host used in the connection. |
required |
port |
int |
The port to use in the connection. Defaults to 22. |
22 |
username |
str |
The username to login. |
None |
password |
str |
The password to login. |
None |
create_directory(self, dir_path)
¶
Create a new directory on the server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir_path |
str |
The name/path of the directory to be created. |
required |
delete_file(self, file_name)
¶
Delete a file on the server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_name |
str |
The name/path of the file to be deleted. |
required |
disconnect(self)
¶
Close the connection with the server.
download_file(self, file_name, destination_folder)
¶
Download a file from the server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_name |
str |
The name/path of the file to be downloaded. |
required |
destination_folder |
str |
The path of the folder where the file will be saved. |
required |
get_current_directory(self)
¶
Get the current working directory.
Returns:
Type | Description |
---|---|
str |
The path of the current directory. |
get_files_list(self)
¶
Get the list of all file and folder names in the current working directory.
Returns:
Type | Description |
---|---|
List[str] |
The list with the name of the files. |
remove_directory(self, dir_path)
¶
Remove a directory on the server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir_path |
str |
The name/path of the directory to be removed. |
required |
rename_file(self, from_name, to_name)
¶
Rename a file on the server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
from_name |
str |
The current file name/path. |
required |
to_name |
str |
The new file name/path. |
required |
set_current_directory(self, dir_path)
¶
Change to the specified directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dir_path |
str |
The name/path of the directory. |
required |
upload_file(self, file_name, destination_path=None)
¶
Upload a file to a destination folder in the server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_name |
str |
The local file to be uploaded. |
required |
destination_path |
str |
The path of the folder where the file will be saved. Defaults to the current working directory. |
None |