[Update] Model : Update処理をthreads処理に変更
- fncにプログレスの数値情報を設定できるように追加 - スプラッシュUIから処理が抜けるのでUIの修正が必要
This commit is contained in:
@@ -8,9 +8,9 @@ from utils import getKeyByValue, isUniqueStrings, strPctToInt
|
|||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
# Common
|
# Common
|
||||||
def callbackUpdateSoftware():
|
def callbackUpdateSoftware(fnc=None):
|
||||||
setMainWindowGeometry()
|
setMainWindowGeometry()
|
||||||
model.updateSoftware()
|
model.updateSoftware(restart=True, fnc=fnc)
|
||||||
|
|
||||||
def callbackRestartSoftware():
|
def callbackRestartSoftware():
|
||||||
setMainWindowGeometry()
|
setMainWindowGeometry()
|
||||||
|
|||||||
22
model.py
22
model.py
@@ -256,6 +256,7 @@ class Model:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def updateSoftware(restart:bool=True, func=None):
|
def updateSoftware(restart:bool=True, func=None):
|
||||||
|
def updateSoftwareTask():
|
||||||
filename = 'VRCT.zip'
|
filename = 'VRCT.zip'
|
||||||
program_name = 'VRCT.exe'
|
program_name = 'VRCT.exe'
|
||||||
folder_name = '_internal'
|
folder_name = '_internal'
|
||||||
@@ -274,17 +275,32 @@ class Model:
|
|||||||
with open(os_path.join(tmp_path, filename), 'wb') as file:
|
with open(os_path.join(tmp_path, filename), 'wb') as file:
|
||||||
for chunk in res.iter_content(chunk_size=1024*5):
|
for chunk in res.iter_content(chunk_size=1024*5):
|
||||||
file.write(chunk)
|
file.write(chunk)
|
||||||
if isinstance(func, Callable):
|
|
||||||
total_chunk += len(chunk)
|
total_chunk += len(chunk)
|
||||||
|
if isinstance(func, Callable):
|
||||||
func(total_chunk/file_size)
|
func(total_chunk/file_size)
|
||||||
|
print(f"downloaded {total_chunk}/{file_size}")
|
||||||
|
|
||||||
with ZipFile(os_path.join(tmp_path, filename)) as zf:
|
with ZipFile(os_path.join(tmp_path, filename)) as zf:
|
||||||
zf.extractall(os_path.join(current_directory, tmp_directory_name))
|
total_files = len(zf.infolist())
|
||||||
|
extracted_files = 0
|
||||||
|
for file_info in zf.infolist():
|
||||||
|
extracted_files += 1
|
||||||
|
zf.extract(file_info, os_path.join(current_directory, tmp_directory_name))
|
||||||
|
if isinstance(func, Callable):
|
||||||
|
func(extracted_files / total_files)
|
||||||
|
print(f"extracted {extracted_files}/{total_files}")
|
||||||
|
|
||||||
copyfile(os_path.join(current_directory, folder_name, "batch", batch_name), os_path.join(current_directory, batch_name))
|
copyfile(os_path.join(current_directory, folder_name, "batch", batch_name), os_path.join(current_directory, batch_name))
|
||||||
command = [os_path.join(current_directory, batch_name), program_name, folder_name, tmp_directory_name, str(restart)]
|
command = [os_path.join(current_directory, batch_name), program_name, folder_name, tmp_directory_name, str(restart)]
|
||||||
Popen(command, cwd=current_directory)
|
Popen(command, cwd=current_directory)
|
||||||
except Exception:
|
except Exception as e:
|
||||||
|
import traceback
|
||||||
|
with open('error.log', 'a') as f:
|
||||||
|
traceback.print_exc(file=f)
|
||||||
webbrowser.open(config.BOOTH_URL, new=2, autoraise=True)
|
webbrowser.open(config.BOOTH_URL, new=2, autoraise=True)
|
||||||
|
th_update_software = threadFnc(updateSoftwareTask)
|
||||||
|
th_update_software.daemon = True
|
||||||
|
th_update_software.start()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def reStartSoftware():
|
def reStartSoftware():
|
||||||
|
|||||||
Reference in New Issue
Block a user