Skip to content

Anyone Still thereeee? This seems deserted.... #4

Open

Description

@krishghorse

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?

Activity

  1. ditsuke commented on Jun 18, 2021

    @ditsuke

    @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.

  2. krishghorse commented on Jun 18, 2021

    @krishghorse
    Author

    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!

  3. ditsuke commented on Jun 19, 2021

    @ditsuke

    @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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions