python-rclone
python-rclone copied to clipboard
Anyone Still thereeee? This seems deserted....
Hey! I was trying to uh upload a file via rclone/python...
My code:
import os
import zipfile
import datetime
import rclone
import time
import logging
logging.basicConfig(
level=logging.DEBUG,
format="%(asctime)s %(name)s [%(levelname)s]: %(message)s")
cfg = """[local]
type = local
nounc = true"""
result = rclone.with_config(cfg).listremotes()
print("Starting compression...")
def zipdir(path, ziph):
# ziph is zipfile handle
for root, dirs, files in os.walk(path):
for file in files:
ziph.write(os.path.join(root, file), os.path.relpath(os.path.join(root, file), os.path.join(path, '..')))
zipf = zipfile.ZipFile(r"G:/forge_server/world_autoBackup.zip", 'w', zipfile.ZIP_DEFLATED)
zipdir(r'G:/forge_server/mods', zipf) # ^^ name of what the file will be outputted as
zipf.close() #^^ PATH TO BACKUP !! CHANGE ME !!
print("Successfully compressed!")
print("Renaming...")
Current_Date = datetime.datetime.today().strftime ('%d-%b-%Y')
#os.rename(r'G:/forge_server/world_autoBackup.zip',r'G:/forge_server/world_autoBackup ' + str(Current_Date) + '.zip')
time.sleep(5)
print("Uploading to google drive via rclone...")
#cfg = """[local]
#type = local
#nounc = true"""
#result = rclone.with_config(cfg).run_cmd(command="copy", extra_args=["G:/forge_server/world_autoBackup.zip", "backup_drive:forge-server-backups"])
print("Finished Upload!")
Its giving me the error:
2021-02-27 01:58:19,689 RClone [DEBUG]: rclone config: ~[local] type = local nounc = true~ 2021-02-27 01:58:19,694 RClone [DEBUG]: Invoking : rclone listremotes --config C:\Users\Krish\AppData\Local\Temp\tmpf3pwwzzw 2021-02-27 01:58:19,887 RClone [DEBUG]: b'' 2021-02-27 01:58:19,942 RClone [WARNING]: 2021/02/27 01:58:19 Failed to load config file "C:\\Users\\Krish\\AppData\\Local\\Temp\\tmpf3pwwzzw": open C:\Users\Krish\AppData\Local\Temp\tmpf3pwwzzw: The process cannot access the file because it is being used by another process.
Any idea how to fix?
@YTMrSnipa I realize you might have figured it out, but this is because python-rclone
is using tempfile.NamedTemporaryFile()
to generate a temporary file that the spawned rclone process uses as the config.
Unfortunately, the temporary file generated this way cannot be opened a second time on Windows!
As I understand, this effectively means that python-rclone
cannot currently be used on Windows.
I'll try to implement a workaround and open a PR soon.
Hey man! Yeah, I did end up figuring it out... I ended up not using rclone at all, I soon came to realize that I can upload and do everything via python itself. Thanks though!
@YTMrSnipa I just opened #5 to fix this issue. I understand you no longer need this, but it might be helpful for others who try using this wrapper on Windows. Can you please reopen?