I made a crude auto-updating application using python, and made exe file using freeze-cx.
First, the app check whether a file of newest version is available on the firebase server, and download the zip file if available. And The app unzip and overwrite the files.
this_file_path = sys.executable if getattr(sys, 'frozen', False) else __file__
path_here = str(Path(this_file_path).parent.absolute())
storagePath = '/version/File'+ver_recent+'.zip'
storage.child(storagePath).download(path='', filename=path_here+'/File.zip')
file_name = path_here+'/File.zip'
output_dir = path_here+"\"
format = "zip"
messagebox.showinfo('Update Ongoing', 'Downloading newest version is done. Extracting file to:'+output_dir)
shutil.unpack_archive(file_name, output_dir, format)
Here, I intention is that my app overwrites all components in the folder.
I confirmed that if I tell my app to overwrite files in other folder, and I saw that other people say that this mechanism is possible.
Is it possible for a running python program to overwrite itself?
However, while running the program, it spits out the error message :
open(targetpath, 'wb') as target:
PermissionError: [Errno13] Permission denied: C\Users\bboyc\Documents\File_0142\lib\_asyncio.pyd
Since I am still new with python, I cannot guess the exact reason. I just cannot understand why the file is refusing to be accessed.
Can anyone please tell me what is happenning or I am missing ? I succeeded overwriting when it was occured for not-running files, so I donot think its the matter of _asyncio.pyd file.
2