SFTP Actions
SFTP Actions allow Marvin to interact with SFTP file servers.
Actions
sftp.change_dir
Change the current directory on SFTP
Parameters:
sftp - SFTP client created by sftp.connect
directory - Path to new directory. This value could be relative or complete path to new folder
Returns:
current_folder - Path to new folder selected
Exceptions:
This action gives no Exceptions
Usage Example
sftp.chdir
Change the current directory on SFTP
Parameters:
sftp - SFTP client created by sftp.connect
directory - Path to new directory. This value could be relative or complete path to new folder
Returns:
current_folder - Path to new folder selected
Exceptions:
This action gives no Exceptions
sftp.close
Closes connection to SFTP server
Parameters:
sftp - SFTP client created by sftp.connect
Returns:
sftp - Will be deleted from Marvin Vars
Exceptions:
This action gives no Exceptions
sftp.create_folder
Creates a new folder on SFTP Server.
Parameters:
sftp - SFTP client created by sftp.connect
remote_path - Complete path to folder creation.
mode (optional)- File access mode for new folder (default=777)
Returns:
This action gives no return
Exceptions:
This action gives no Exceptions
sftp.connect
Open a new connection to SFTP server
Parameters:
host - SFTP Server host
username - Username to connect on SFTP Server
password (optional)- Password to connect on SFTP Server, if passwrod is necessary to connect (default=no password)
port (optional)- SFTP Server port for connection (default=22)
default_path (optional)- Path where SFTP client must be after connection (default=root)
private_key (optional)- Path to private key used to connect (default=no private key needed)
private_key_pass=None - Password for the private key used to connect (default=no private key password needed)
Returns:
sftp - SFTP client
Exceptions:
This action gives no Exceptions
sftp.current_folder
Return the path of current folder.
Parameters:
sftp - SFTP client created by sftp.connect
Returns:
current_folder - Path to new folder selected
Exceptions:
This action gives no Exceptions
sftp.delete
Deletes the given file or folder
Parameters:
sftp - SFTP client created by sftp.connect
remote_path - Path to the file or folder to be deleted.
Returns:
This action gives no return
Exceptions:
This action gives no Exceptions
sftp.download
Downloads a file from SFTP Server.
Parameters:
sftp - SFTP client created by sftp.connect
remote_path - Path to the file or folder to be deleted.
local_path - Path to local machine, where file must be saved
Tip
Don't forget to include file name on local_path
Returns:
download_path - Local path to downloaded file
Exceptions:
This action gives no Exceptions
sftp.file_exists
Verify is a file exists on SFTP Server.
Parameters:
sftp - SFTP client created by sftp.connect
remote_path - Remote path for the file
Returns:
exists - True
if file exists on server False
if don't
Exceptions:
This action gives no Exceptions
sftp.folder_exists
Verify is a folder exists on SFTP Server.
Parameters:
sftp - SFTP client created by sftp.connect
remote_path - Remote path for the folder
Returns:
exists - True
if folder exists on server False
if don't
Exceptions:
This action gives no Exceptions
sftp.list
List all files and folder on current path or on the given remote path.
Parameters:
sftp - SFTP client created by sftp.connect
remote_path (optional)- Remote path to folder which files and folders must be listed (default=current path)
Returns:
items - Name of all files and folder inside currrent path or given remote_path
Exceptions:
This action gives no Exceptions
Usage Example
sftp.list_files
List all files on current path or on the given remote path.
Parameters:
sftp - SFTP client created by sftp.connect
remote_path (optional)- Remote path to folder which files must be listed (default=current path)
Returns:
files - Name of all files inside currrent path or given remote_path
Exceptions:
This action gives no Exceptions
Usage Example
sftp.list_folders
List all folders on current path or on the given remote path.
Parameters:
sftp - SFTP client created by sftp.connect
remote_path (optional)- Remote path to folder which folders must be listed (default=current path)
Returns:
folders - Name of all folder inside currrent path or given remote_path
Exceptions:
This action gives no Exceptions
Usage Example
sftp.upload
Uploads a local file to SFTP Server on the current folder.
Parameters:
sftp - SFTP client created by sftp.connect
local_path - Local path to the file to be uploaded
Returns:
This action given o return
Exceptions:
This action gives no Exceptions