Rclone copy in python script

New user here. We are wanting to use rclone in an existing script that we use to order satellite imagery. The imagery files are delivered via GCS, but we want to back them up in Dropbox. Using rclone in windows cmd works perfectly.

rclone copy gcs:gcs/path/image.tif dropbox:dropbox/destination/folder/path/rclone_test_2

However, running the exact same command in Python 2 using os.popen() or subprocess does not work. This includes using a single string with no variable substitutions etc.

rclone_command = ‘rclone copy gcs:’ + gcs_add + ’ dropbox:’ + dbxName
os.popen(rclone_command)

or

subprocess.call([‘cmd’, ‘rclone copy gcs:’,gcs_add,’ dropbox:’,dbxName])

Any ideas?

When using subprocess you need to put each parameter as a separate argument, so I think this should do it. I don’t think you should need the cmd either.

subprocess.call(['rclone', 'copy', 'gcs:'+gcs_add, 'dropbox:'+dbxName])
1 Like

Thanks for the reply. It was just an issue with the location of rclone.exe. Running the script with rclone.exe in the same folder works perfectly.

Thanks,
Andrew

1 Like