A python wrapper for rclone that makes rclone's functionality usable in python applications.
—
Functions for creating, configuring, and managing cloud storage remotes. Supports OAuth authentication, custom configuration options, and comprehensive remote validation across 70+ cloud storage providers.
Create new remotes with OAuth authentication and custom configuration options for any supported cloud storage provider.
def create_remote(remote_name: str, remote_type: Union[str, RemoteTypes],
client_id: Union[str, None] = None, client_secret: Union[str, None] = None, **kwargs):
"""
Creates a new rclone remote with name, type, and configuration options.
Parameters:
- remote_name (str): Name for the new remote (must be unique)
- remote_type (Union[str, RemoteTypes]): Cloud provider type (e.g., "onedrive", RemoteTypes.dropbox)
- client_id (str, optional): OAuth Client ID for custom authentication
- client_secret (str, optional): OAuth Client Secret for custom authentication
- **kwargs: Additional key-value pairs for rclone config create command
Returns:
None
Raises:
Exception: If remote with same name already exists
RcloneException: If remote creation fails
"""List all configured remotes and check for specific remote existence.
def get_remotes() -> List[str]:
"""
Retrieves list of all configured rclone remotes.
Returns:
List[str]: List of remote names with trailing colons (e.g., ['onedrive:', 'box:'])
"""
def check_remote_existing(remote_name: str) -> bool:
"""
Checks if a specific rclone remote is configured.
Parameters:
- remote_name (str): Name of remote to check (with or without trailing ':')
Returns:
bool: True if remote exists, False otherwise
"""from rclone_python import rclone
from rclone_python.remote_types import RemoteTypes
# Create OneDrive remote with default OAuth
rclone.create_remote('onedrive', RemoteTypes.onedrive)
# Create Dropbox remote using string type
rclone.create_remote('dropbox', 'dropbox')
# Check if remote was created
if rclone.check_remote_existing('onedrive'):
print("OneDrive remote successfully created")from rclone_python import rclone
from rclone_python.remote_types import RemoteTypes
# Create remote with custom OAuth credentials
rclone.create_remote(
'my_onedrive',
RemoteTypes.onedrive,
client_id='your_client_id_here',
client_secret='your_client_secret_here'
)from rclone_python import rclone
from rclone_python.remote_types import RemoteTypes
# Create S3 remote with additional configuration
rclone.create_remote(
'aws_s3',
RemoteTypes.s3,
access_key_id='your_access_key',
secret_access_key='your_secret_key',
region='us-west-2',
provider='AWS'
)
# Create SFTP remote with authentication
rclone.create_remote(
'my_server',
RemoteTypes.sftp,
host='server.example.com',
user='username',
port='22',
key_file='/path/to/private/key'
)from rclone_python import rclone
from rclone_python.remote_types import RemoteTypes
# List all existing remotes
existing_remotes = rclone.get_remotes()
print(f"Configured remotes: {existing_remotes}")
# Check before creating to avoid conflicts
remote_name = 'my_drive'
if not rclone.check_remote_existing(remote_name):
rclone.create_remote(remote_name, RemoteTypes.drive)
print(f"Created new remote: {remote_name}")
else:
print(f"Remote {remote_name} already exists")
# Verify creation
updated_remotes = rclone.get_remotes()
print(f"Updated remotes: {updated_remotes}")The RemoteTypes enum includes 72 different cloud storage providers:
Including enterprise storage, backup services, file hosting platforms, and specialized cloud storage solutions.
Different remote types support various configuration parameters:
client_id: Custom OAuth application IDclient_secret: Custom OAuth application secrettoken: Pre-obtained OAuth token (advanced)access_key_id: Access key for authenticationsecret_access_key: Secret key for authenticationregion: Storage regionendpoint: Custom S3 endpoint URLprovider: Specific S3 provider (AWS, Minio, etc.)host: Server hostname or IPuser: Username for authenticationport: Connection portkey_file: Path to SSH private keypassword: Password authenticationInstall with Tessl CLI
npx tessl i tessl/pypi-rclone-python