Rclone for the python environment and your virtual environment. Comes bundled with the Rclone binary so, no need to have Rclone pre-installed.
- 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
-
If you already have 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)
-
If you already have your own rclone.conf and want to use it you can set the paths using the the
pyclone.set_config_path()
method:import pyclone pyclone.set_config_path(config="/path/to/config")
-
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
-
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()
There are three major classes in Pyclone:
- pyclone.Pyclone()
- pyclone.RemoteManager()
- pyclone.Remote()
-
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()
-
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(response.text) Ommited.. ... ...
-
import pyclone pyc = pyclone.Pyclone() pyc.config_create('remote_type', 'remote_name', '[email protected]', 'remote_pass')
-
pyc.config_delete('remote_name')
-
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')
-
pyc.ls('remote:path')
-
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']
-
remotes.create('remote_type', 'remote_name', '[email protected]', 'remote_pass') remotes.delete('remote_name')
-
This returns a
Remote
object that inherits most of its functionality from the Pyclone object.remote_A = remotes.get_remote('remote_A')
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()
- Non-blocking subprocesses
- pyclone.Remote.check()
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.