Automatic update method with python Pyinstaller exe

What you want to do

--When you open the app, check for updates --If there is an update, the update will start automatically --Restart the app

Let's go!

When you open the app, check for updates

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.

If there is an update, the update will start automatically

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

Restart the app

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

Summary

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

Automatic update method with python Pyinstaller exe
python chromedriver automatic update
Kernel Method with Python
[Python] Calculation method with numpy
Automatic update of Python module
PyInstaller memorandum Convert Python [.py] to [.exe] with 2 lines
[Python Kivy] How to create an exe file with pyinstaller
Replace dictionary value with Python> update ()
Make Scrapy an exe with Pyinstaller
Automatic image interpolation with OpenCV and Python (Fast Marching Method, Navier-Stokes)
Python update (2.6-> 2.7)
Python script written in PyTorch is converted to exe with PyInstaller
Suddenly with Python PyInstaller No module named pyinstaller
Clogged with python update of GCP console ①
Shared screen screenshot exe app with python
EXE the application created with PyQt5 with PyInstaller
Creating an exe file with Python PyInstaller: PC freezes in parallel processing
FizzBuzz with Python3
Make Python scripts into Windows-executable .exes with Pyinstaller
Scraping with Python
Statistics with python
Automatic operation of Chrome with Python + Selenium + pandas
Scraping with Python
Python with Go
Clogged with python update of GCP console ② (Solution)
Twilio with Python
Integrate with Python
Move THORLABS automatic stage with Python [for research]
Play with 2016-Python
AES256 with python
Tested with Python
Develop Windows apps with Python 3 + Tkinter (exe file)
python starts with ()
with syntax (Python)
Bingo with python
Zundokokiyoshi with python
youtube-dl update method
Johnson method (python)
Excel with Python
[Python] Semi-Lagrange method
Microcomputer with Python
Cast with python
Create an exe file that works in a Windows environment without Python with PyInstaller
[Python] What to do when No module named'pyproj.datadir' appears when Exe is done with PyInstaller
Automatic JIRA ticket creation with slack bot ~ slack bot development with python ① ~
Destroy the intermediate expression of the sweep method with Python
Automatic follow on Twitter with python and selenium! (RPA)
Creating ρ method for elliptic curve cryptography with python
Make a CSV formatting tool with Python Pandas PyInstaller
I can't exe a project using PyWebView with PyInstaller
I moved the automatic summarization API "summpy" with python3.
Serial communication with Python
Zip, unzip with python
Django 1.11 started with Python3.6
Primality test with Python
Python with eclipse + PyDev.
Socket communication with Python
Data analysis with python 2
Scraping with Python (preparation)
Learning Python with ChemTHEATER 03
Sequential search with Python