Giter VIP home page Giter VIP logo

rclone's Introduction

Rclone for Python

๐Ÿš€ Python wrapper for rclone.

Supported Python versions PEP8

Requirements

โฌ‡๏ธ Installation

pip install rclone

โŒจ๏ธ Usage

from rclone.rclone import Rclone

rc = Rclone()

๐Ÿ“• Examples

pathname = 'gdrive:/remote/path'  # you can also use a local path


rc.copy('foo.txt', 'remote:/path/to/dst')
# 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 0.16/0.16 [00:00<00:00,  1.13MB/s]
rc.move('bar.bin', 'remote:/path/to/dst')
# 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 0.16/0.16 [00:00<00:00,  1.34MB/s]
rc.unit = 'B'
rc.copy('foo.txt', 'remote:/path/to/dst')
# 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 159414.0/159414.0 [00:00<00:00, 1003822.00B/s]
rclone.ls('remote:/path/to/dir')
# ['foo.bin', 'bar.txt', 'foo/']
rclone.lsjson('remote:/path/to/dir')
# [
#     {
#         'Path': 'bar.txt',
#         'Name': 'bar.txt',
#         'Size': 0,
#         'MimeType': 'text/plain; charset=utf-8',
#         'ModTime': '2022-03-22T13:07:53.557168464-04:00',
#         'IsDir': False
#     }
# ]
rclone.ls('remote:/path/to/dir', '-R')  # you can supply additional flags to any command as positional argments
# ['foo.bin', 'bar.txt', 'foo/', 'foo/foo1.txt', 'foo/foo2', 'foo/bar/foobar.txt']
rclone.size('remote:/path/to/dir')
# {'total_objects': 5, 'total_size': 170397}

You can also use whatever subcommands/flags with execute():

# 
rclone.execute('ls "remote:/path/to/dir" --exclude *.txt')
#       27 foo.bin
#   159414 foo.csv.zip
#     4808 rclone.py

rclone's People

Contributors

alyetama avatar

Stargazers

elburg avatar Dylan Roy avatar Jorge Gomez avatar  avatar

Watchers

 avatar

Forkers

metaldevops

rclone's Issues

the scripts fails when there are rclone warnings

$ rclone lsjson googledrive:dir1
[
2023/06/19 11:30:56 NOTICE: Dangling shortcut "GoogleDoc1" detected
2023/06/19 11:30:56 NOTICE: Dangling shortcut "GoogleDoc2" detected
{"Path":"GoogleDoc3.docx","Name":"GoogleDoc3.docx","Size":-1,"MimeType":"application/vnd.openxmlformats-officedocument.wordprocessingml.document","ModTime":"2010-11-10T14:09:30.727Z","IsDir":false,"ID":"1lfoJixyFffiNT9YDz9QDiJ7vsOq9sE9YedQGlJLSsEz"},
...

When I use the python rclone library, it takes the full output, including these NOTICE warnings, and then it fails to parse the json content.

the path needs to be shell quoted

the path needs to be shell quoted.
my current workaround is like this:

path="owncloud:example dir with space/file.txt"
from rclone.rclone import Rclone
import shlex
rc = Rclone()
rc.lsjson(shlex.quote(path))

i don't know what is best, to add the shlex.quote from inside your script, or from outside just as I am doing here (the rclone functions allow to pass other parameters, and path might not be the first one). If the second choice is best, then this could be documented in your README.md file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.