Merge branch 'autoUpdate' into UI_2.0

This commit is contained in:
misyaguziya
2023-10-04 11:37:04 +09:00
3 changed files with 35 additions and 2 deletions

View File

@@ -1 +1 @@
pyinstaller --onedir --onefile --windowed --clean --icon="./img/vrct_logo_mark_black.ico" --add-data "./img;img/" --add-data "./locales;locales/" --name VRCT --exclude-module numpy --exclude-module pandas --exclude-module matplotlib --exclude-module PyQt5 main.py pyinstaller --onedir --onefile --windowed --clean --icon="./img/vrct_logo_mark_black.ico" --add-data "./img;img/" --add-data "./locales;locales/" --add-data "./update.bat;./" --name VRCT --exclude-module numpy --exclude-module pandas --exclude-module matplotlib --exclude-module PyQt5 main.py

View File

@@ -1,6 +1,9 @@
import sys import sys
from zipfile import ZipFile
from subprocess import Popen
from os import makedirs from os import makedirs
from os import path as os_path from os import path as os_path, rename as os_rename, mkdir as os_mkdir
from shutil import rmtree
from datetime import datetime from datetime import datetime
from logging import getLogger, FileHandler, Formatter, INFO from logging import getLogger, FileHandler, Formatter, INFO
from time import sleep from time import sleep
@@ -229,6 +232,30 @@ class Model:
print("software version", "now:", config.VERSION, "new:", new_version) print("software version", "now:", config.VERSION, "new:", new_version)
return update_flag return update_flag
@staticmethod
def updateSoftware():
filename = 'download.zip'
program_name = 'VRCT.exe'
temporary_name = '_VRCT.exe'
tmp_directory_name = 'tmp'
batch_name = 'update.bat'
current_directory = os_path.dirname(sys.argv[0])
program_directory = os_path.dirname(__file__)
os_mkdir(os_path.join(current_directory, tmp_directory_name))
res = requests_get(config.GITHUB_URL)
url = res.json()['assets'][0]['browser_download_url']
res = requests_get(url, stream=True)
with open(os_path.join(current_directory, tmp_directory_name, filename), 'wb') as file:
for chunk in res.iter_content(chunk_size=1024):
file.write(chunk)
with ZipFile(os_path.join(current_directory, tmp_directory_name, filename)) as zf:
zf.extract(program_name, os_path.join(current_directory, tmp_directory_name))
os_rename(os_path.join(current_directory, tmp_directory_name, program_name), os_path.join(current_directory, temporary_name))
rmtree(os_path.join(current_directory, tmp_directory_name))
command = [os_path.join(program_directory, batch_name), program_name, temporary_name]
Popen(command)
@staticmethod @staticmethod
def getListInputHost(): def getListInputHost():
return [host for host in getInputDevices().keys()] return [host for host in getInputDevices().keys()]

6
update.bat Normal file
View File

@@ -0,0 +1,6 @@
taskkill /im %1 /F
timeout 2
del /f %1
timeout 2
rename %2 %1
START "" %1