Skip to main content

A python wrapper for rclone.

Project description

MIT License PyPI version

rclone-python ☁️

A python wrapper for rclone that makes rclone's functionality usable in python. rclone needs to be installed on the system for the wrapper to work.

demo gif

Features ⚒️

  • Copy, move and sync files between remotes
  • Delete and prune files/directories
  • List files in a directory including properties of the files.
  • List available remotes.
  • Generate hashes from files or validate them with their hashsum.
  • Create new remotes
  • Check available remotes
  • Create and manage public links.
  • Check the currently installed rclone versions and if updates are available.

Installation 💾

rclone_python can be installed using pip

pip install rclone-python

or by cloning this repository and running from within the root of the project

pip install .

How to use 💡

All functionally of this wrapper is accessible through rclone. The following example checks if rclone is installed.

from rclone_python import rclone

print(rclone.is_installed())
True

Create new remote

Create a new rclone remote connection with rclone's default client-id and client-secret.

from rclone_python import rclone
from rclone_python.remote_types import RemoteTypes

rclone.create_remote('onedrive', RemoteTypes.onedrive)

Additionally, client-id and client-secret can be used with many cloud providers.

from rclone_python import rclone
from rclone_python.remote_types import RemoteTypes

rclone.create_remote('onedrive', RemoteTypes.onedrive, client_id='YOUR_CLIENT_ID', client_secret='YOUR_CLIENT_SECRET')

Copy

from rclone_python import rclone

# copy all file in the test_dir on OneDrive to the local data folder.
rclone.copy('onedrive:data', 'data', ignore_existing=True, args=['--create-empty-src-dirs'])
Copying onedrive:data to data ⠸ ━━━━━━━━━━━━━━━━━━╸━━━━━━━━━━━━━━━━━━━━━  47% 110.0/236.5 MiB 0:00:04
 ├─video1.webm                ⠸ ━━━━━━━━━━━━╺━━━━━━━━━━━━━━━━━━━━━━━━━━━  31% 24.4/78.8 MiB   0:00:06
 ├─video2.webm                ⠸ ━━━━━━━━━━━━━━━━━━╺━━━━━━━━━━━━━━━━━━━━━  45% 35.5/78.8 MiB   0:00:03
 └─video3.webm                ⠸ ━━━━━━━━━━━━━╸━━━━━━━━━━━━━━━━━━━━━━━━━━  35% 27.6/78.8 MiB   0:00:05

Delete

Delete a file or a directory. When deleting a directory, only the files in the directory (and all it's subdirectories) are deleted, but the folders remain.

from rclone_python import rclone

# delete a specific file on onedrive
rclone.delete('onedrive:data/video1.mp4')

Prune

from rclone_python import rclone

# remove the entire test_dir folder (and all files contained in it and it's subdirectories) on onedrive
rclone.purge('onedrive:test_dir')

Get Hash

from rclone_python import rclone
from rclone_python.hash_types import HashTypes

print(rclone.hash(HashTypes.sha1, "box:data")
{'video1.webm': '3ef08d895f25e8b7d84d3a1ac58f8f302e33058b', 'video3.webm': '3ef08d895f25e8b7d84d3a1ac58f8f302e33058b', 'video2.webm': '3ef08d895f25e8b7d84d3a1ac58f8f302e33058b'}

Custom Progressbar

You can use your own rich progressbar with all transfer operations. This allows you to customize the columns to be displayed. A list of all rich-progress columns can be found here.

from rclone_python import rclone

from rich.progress import (
    Progress,
    TextColumn,
    BarColumn,
    TaskProgressColumn,
    TransferSpeedColumn,
)

pbar = Progress(
    TextColumn("[progress.description]{task.description}"),
    BarColumn(),
    TaskProgressColumn(),
    TransferSpeedColumn(),
)
rclone.copy("data", "box:rclone_test/data1", pbar=pbar)
Copying data to data1 ━━━━━━╸━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━  17% 5.3 MB/s                                                                                                            
 ├─video1.mp4         ━━━━━━━━━━━━━━━╺━━━━━━━━━━━━━━━━━━━━━━━━  38% 4.2 MB/s                                                                                                            
 ├─video2.mp4         ━╸━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   5% 1.6 MB/s
 └─another.mp4        ━╸━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   4% 1.4 MB/s

Debug

For debugging progress related functionality, set the DEBUG flag to true:

rclone.DEBUG = True

This will make the wrapper print the raw rclone progress.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rclone_python-0.1.15.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

rclone_python-0.1.15-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file rclone_python-0.1.15.tar.gz.

File metadata

  • Download URL: rclone_python-0.1.15.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for rclone_python-0.1.15.tar.gz
Algorithm Hash digest
SHA256 d60f2168ff4a98f3fba9fba4e01c86253e15fa62fa436926324746ae9d719e06
MD5 4b39b3a1aab91fefec469d76fe329e8a
BLAKE2b-256 1913a073117c835a6967c47563d6c0c20f674641195f2afe94b87febdb0f436a

See more details on using hashes here.

File details

Details for the file rclone_python-0.1.15-py3-none-any.whl.

File metadata

File hashes

Hashes for rclone_python-0.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 2098606479b810f15fbbc357d0ebdd44ad5353757c2b10f5ffa37e4115f70d7e
MD5 2a40decb92a0b3914f2d0be0f2e4f561
BLAKE2b-256 773cce7a4ef3c38ad14b4c1b6f451a118920ab5ffcedd2bbacb284e40d77032d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page