Python interface for rclone
Project description
Pyclone
Rclone for your python environment and your virtual environment.Comes bundled with the Rclone binary so, no need to have Rclone pre-installed.
Installation
- The installation automatically downloads the rclone binaries so there is no prerequisite to having rclone prior.
- Run the following to install:
pip install pyclone-module
Configuration
-
If you already have the rclone pre-installed and want to use that specific binary you can set the paths using the the
pyclone.set_path()
method:import pyclone pyclone.set_path(path=PATH_TO_RCLONE,config=PATH_TO_CONFIG)
Usage
CLI
-
Pyclone is a wrapper or rclone, so you can use the same commands you regularly use in rclone. Visit rclone.org/commands for further information.
user:~$ pyclone config
Import Pyclone into your projects
-
Importing pyclone into your projects to have programatic control of rclone is as simple as
import pyclone
. Further usage will require some knowlegde on some of the classes.import pyclone pyc = pyclone.Pyclone()
Pyclone classes
There are three major classes in Pyclone:
- pyclone.Pyclone()
- pyclone.RemoteManager()
- pyclone.Remote()
1. pyclone.Pyclone()
-
This is the main pyclone object that is ressponsible for communicating with the Rclone shell. You will be dealing with this class mostly. Instanitate it like this
import pyclone pyc = pyclone.Pyclone()
1.1 pyclone.Pyclone().execute(command)
-
Pyclone utilizes the
subprocess
module to communicate with the shell and theexecute
method allows you to send commands directly to rclone. Commands have to are expected to be in list format. This returns a Response object which contains the text, stdout, stderr, responsecode and args instance variables.>>> import pyclone >>> command = ['help'] >>> pyc = pyclone.Pyclone() >>> response = pyc.execute(command) >>> print(reponse.responsecode) 0 >>> print(repsponse.text) Ommited.. ... ...
1.2 Create a Remote pyc.config_create()
-
import pyclone pyc = pyclone.Pyclone() pyc.config_create('remote_type', 'remote_name', 'remote@email.com', 'remote_pass')
1.3 Delete a remote pyc.config_delete()
-
pyc.config_delete('remote_name')
1.4 Move/Copy pyc.copy()/pyc.move()
-
Note that the the remote has to be appended by a colon at the end which will end up looking like: pyc.copy(file.zip, 'remote:')
pyc.copy('src:path', 'dest:path') pyc.move('src:path', 'dest:path')
1.5 List directory (ls) pyc.copy()/pyc.move()
-
pyc.ls('remote:path')
Using the Remote Manager and Remote object
2 pyclone.RemoteManager()
-
The Remote Mangager brings everything together by mangaing your remotes, and extending the functionality of the Pyclone and Remote objects.
>>> import pyclone >>> remotes = pyclone.RemoteManager() >>> remotes.show() ['remote_A', 'remote_B']
1.2 Create/Deleting a Remote remotes.create()/remotes.delete()
-
remotes.create('remote_type', 'remote_name', 'remote@email.com', 'remote_pass') remotes.delete('remote_name')
Remote Objects
2.1 Get a Remote remotes.get_remote()
-
This returns a
Remote
object that inherits most of its functionality from the Pyclone object.remote_A = remotes.get_remote('remote_A')
2.2 Remote methods
remote.ls()
remote.copy('file', dl=False)
- If
dl=True
this will download the file from the remote.
- If
remote.move('file:path', dl=False)
- If
dl=True
this will download the file from the remote.
- If
remote.delete('file:path')
remote.size()
Future:
- Non-blocking subprocesses
- pyclone.Remote.check()
Developing pyclone
To install pyclone, along with all the tools you need to develop and run tests, run the following in your virtualenv:
user:~$ pip install -e .[dev]
Drop some feedback, bugs, and feature requests if you can.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pyclone-module-1.53.5.tar.gz
.
File metadata
- Download URL: pyclone-module-1.53.5.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ada1fe6df910a40ad4866155afbb82b8c37d019521d5401e7ca8e1f43cc096f |
|
MD5 | 7893467040dd1790fcf7332bd93f66c2 |
|
BLAKE2b-256 | f0c0c33c8d2b41fc08a5dad2456efe289011912bc86180e613e14c5fc7366d33 |