--When you open the app, check for updates --If there is an update, the update will start automatically --Restart the app
Let's go!
hogehoge.spec
・ ・ Abbreviation
exe = EXE(pyz,
Tree('version',prefix='version'), #add to
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='hogehoge_mac',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True )
Add version and make exe. Put system.json under the version directory
system.json
[
{
"version": "1.9"
}
]
#Version check
if common.system["version"] != str(common.information[0].system_version):
Compare the created version with the database version I omit reading json and getting it from the database.
#download
file_size = 50029115
res = requests.get(self.url, stream=True)
pbar = tqdm(total=file_size, unit="B", unit_scale=True)
with open(self.save_name, 'wb') as file:
for chunk in res.iter_content(chunk_size=1024):
file.write(chunk)
pbar.update(len(chunk))
pbar.close()
It looks good when downloaded with automatic update, tqdm. The point is to save save_name with a different name than the exe.
#Batch execution
command = "rename.cmd " + self.save_name + " " + self.rename_name + " " + self.delete_name
subprocess.Popen(command.split())
After downloading, kick the batch to delete files, rename and launch the app in the batch.
# rename.cmd
taskkill /im %2 /F
timeout 2
del /f %3
timeout 2
rename %1 %2
%3
Cut the running process just in case. Delete the file before the update. Rename the updated file. Restart.
--Have the current version in json --Keep the latest version in the database --Download with python --Rename in batch
Within python, you can't rename the app that's running right now, so you'll have to kick the batch.
Recommended Posts