You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey! I was trying to uh upload a file via rclone/python...
My code:
importosimportzipfileimportdatetimeimportrcloneimporttimeimportlogginglogging.basicConfig(
level=logging.DEBUG,
format="%(asctime)s %(name)s [%(levelname)s]: %(message)s")
cfg="""[local]type = localnounc = true"""result=rclone.with_config(cfg).listremotes()
print("Starting compression...")
defzipdir(path, ziph):
# ziph is zipfile handleforroot, dirs, filesinos.walk(path):
forfileinfiles:
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 aszipf.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.
@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?
Reacted by Broncio Aguilar-Sanjuan, jonjphayward and Lucas Fernando Cardoso Nunes
Activity
ditsuke commentedon Jun 18, 2021
@YTMrSnipa I realize you might have figured it out, but this is because
python-rcloneis usingtempfile.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-rclonecannot currently be used on Windows.I'll try to implement a workaround and open a PR soon.
krishghorse commentedon Jun 18, 2021
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!
ditsuke commentedon Jun 19, 2021
@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?