¶
botcity.plugins.ftp.BotFTPPlugin
¶
__init__(hostname, username=None, password=None)
¶
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(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:
| Name | Type | Description |
|---|---|---|
str |
str
|
The full path of the created directory. |
delete_file(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()
¶
Close the connection with the server.
download_file(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()
¶
Get the current working directory.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The path of the current directory. |
get_files_list()
¶
Get the list of all file and folder names in the current working directory.
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: The list with the name of the files. |
list_files()
¶
Prints the files and folders presents in the current folder.
remove_directory(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(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(dir_path)
¶
Change to the specified directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dir_path
|
str
|
The name/path of the directory. |
required |
upload_file(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.BotSFTPPlugin
¶
__init__(hostname, port=22, username=None, password=None)
¶
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(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(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()
¶
Close the connection with the server.
download_file(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()
¶
Get the current working directory.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The path of the current directory. |
get_files_list()
¶
Get the list of all file and folder names in the current working directory.
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: The list with the name of the files. |
remove_directory(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(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(dir_path)
¶
Change to the specified directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dir_path
|
str
|
The name/path of the directory. |
required |
upload_file(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
|