RClone

class rclone_manager.rclone.RClone(src, dst, *args, **kwargs)

Bases: object

Basic rclone command line tool wrapper. This class is used to create and use rclone commands. If you want to use rclone as a python library, use this.

Parameters:
  • src – Source path

  • dst – Destination path

  • args – Flags

  • kwargs – Options & Config

property cmd

Get rclone command.

Returns:

RClone command

Return type:

str

copy()

Set method to copy.

Returns:

self

Return type:

RClone

property flags

Get rclone flags.

Returns:

RClone flags

Return type:

str

property is_running

Check if process is running.

Returns:

True if process is running, False otherwise

Return type:

bool

property is_started

Check if process is started.

Returns:

True if process is started, False otherwise

Return type:

bool

property method

Get rclone method.

Returns:

RClone method

Return type:

str

move()

Set method to move.

Returns:

self

Return type:

RClone

property options

Get rclone options.

Returns:

RClone options

Return type:

str

run(wait=True, wait_timeout=None)

Run rclone command.

Parameters:
  • wait (bool) – Wait for process to finish

  • wait_timeout (int) – Timeout for process to finish

sync()

Set method to sync.

Returns:

self

Return type:

RClone

terminate()

Terminate process.

RCloneJob

class rclone_manager.job.RCloneJob(src, dst, callback: Optional[callable] = None, *args, **kwargs)

Bases: RClone

This class is a subclass of the RClone class, and it is used to create a job object that can be used to run a job on the cluster. It has a thread that updates the job progress in real time. It also has a callback function that is called when the job is finished or terminated.

Parameters:
  • src (str) – Source path

  • dst (str) – Destination path

  • callback (callable) – Callback function

  • args – Flags

  • kwargs – Options & Config

property is_finished

Check if job is finished.

Returns:

True if job is finished, False otherwise

Return type:

bool

run(*args, **kwargs)

Run rclone command.

Parameters:
  • args – Flags

  • kwargs – Options & Config (will override the ones passed to the constructor)

Returns:

RCloneJob object

Return type:

RCloneJob

property stats

Get job stats.

Returns:

Job stats

Return type:

dict

terminate()

Terminate job.

RCloneTask

class rclone_manager.task.RCloneTask(job: Optional[RCloneJob] = None, schedule: Optional[RCloneSchedule] = None, is_enabled=True, *args, **kwargs)

Bases: object

This is a wrapper for the RCloneJob class. It is used to schedule jobs to run at a specific time.

Parameters:
  • job (RCloneJob) – RCloneJob object

  • schedule (RCloneSchedule) – RCloneSchedule object

  • is_enabled (bool) – Enable or disable task

  • args – Arguments to pass to RCloneJob

  • kwargs – Keyword arguments to pass to RCloneJob

property end_time

Get end time of the task.

Returns:

End time

Return type:

datetime.datetime

result_handler(job: RCloneJob)

This is a callback function that is called when the job is finished. It will log the job stats.

Parameters:

job (RCloneJob) – RCloneJob object

run(*args, **kwargs)

Run the task. This will run the job and schedule the job to run again at the specified time.

Parameters:
  • args – Arguments to pass to RCloneJob

  • kwargs – Keyword arguments to pass to RCloneJob

property start_time

Get start time of the task.

Returns:

Start time

Return type:

datetime.datetime

RCloneSchedule

class rclone_manager.schedule.RCloneSchedule(start_cron=None, end_cron=None, blocking=True)

Bases: object

It schedules a task to run at a certain time, and if an end time is specified, it will also schedule the task to terminate at that time. It uses APScheduler to schedule the tasks.

Parameters:
  • start_cron (str) – Cron expression for when the task should start

  • end_cron (str) – Cron expression for when the task should end

  • blocking (bool) – If True, the scheduler will block the thread. If False, the scheduler will run in the background.

property end_trigger

Get end trigger.

Returns:

End trigger object

Return type:

CronTrigger

schedule_start(task: RCloneTask, *args, **kwargs)

Schedule the task to start at the specified time. If an end time is specified, it will also schedule the task to end at that time.

Parameters:
  • task (RCloneTask) – RCloneTask object

  • args – Arguments to pass to RCloneJob

  • kwargs – Keyword arguments to pass to RCloneJob

property start_trigger

Get start trigger.

Returns:

Start trigger object

Return type:

CronTrigger