mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-03 17:39:42 +02:00
feat: update download process to use temporary installer path and improve silent installation
This commit is contained in:
@@ -68,3 +68,4 @@ Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: de
|
|||||||
|
|
||||||
[Run]
|
[Run]
|
||||||
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
|
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
|
||||||
|
Filename: "{app}\{#MyAppExeName}"; Flags: nowait skipifnotsilent
|
||||||
|
|||||||
+10
-20
@@ -153,8 +153,12 @@ def _find_install_path():
|
|||||||
|
|
||||||
|
|
||||||
def download_update(latest_version):
|
def download_update(latest_version):
|
||||||
|
import tempfile
|
||||||
|
import time
|
||||||
|
|
||||||
new_filename = f"SoftwareManager-dev-{latest_version.replace('-dev', '')}-windows-setup.exe"
|
new_filename = f"SoftwareManager-dev-{latest_version.replace('-dev', '')}-windows-setup.exe"
|
||||||
url = f"https://github.com/KeksPirates/SoftwareManager/releases/latest/download/SoftwareManager-dev-{latest_version.replace('-dev', '')}-windows-setup.exe"
|
url = f"https://github.com/KeksPirates/SoftwareManager/releases/latest/download/SoftwareManager-dev-{latest_version.replace('-dev', '')}-windows-setup.exe"
|
||||||
|
installer_path = os.path.join(tempfile.gettempdir(), new_filename)
|
||||||
|
|
||||||
progress = QtWidgets.QProgressDialog("Downloading installer...", None, 0, 0)
|
progress = QtWidgets.QProgressDialog("Downloading installer...", None, 0, 0)
|
||||||
progress.setWindowTitle("Updating")
|
progress.setWindowTitle("Updating")
|
||||||
@@ -179,11 +183,11 @@ def download_update(latest_version):
|
|||||||
progress.setValue(int(downloaded * 100 / total))
|
progress.setValue(int(downloaded * 100 / total))
|
||||||
QtWidgets.QApplication.processEvents()
|
QtWidgets.QApplication.processEvents()
|
||||||
|
|
||||||
with open(new_filename, "wb") as f:
|
with open(installer_path, "wb") as f:
|
||||||
for chunk in chunks:
|
for chunk in chunks:
|
||||||
f.write(chunk)
|
f.write(chunk)
|
||||||
|
|
||||||
if not os.path.exists(new_filename):
|
if not os.path.exists(installer_path):
|
||||||
progress.close()
|
progress.close()
|
||||||
raise FileNotFoundError("Executable not found")
|
raise FileNotFoundError("Executable not found")
|
||||||
|
|
||||||
@@ -191,24 +195,10 @@ def download_update(latest_version):
|
|||||||
progress.setValue(100)
|
progress.setValue(100)
|
||||||
QtWidgets.QApplication.processEvents()
|
QtWidgets.QApplication.processEvents()
|
||||||
|
|
||||||
proc = subprocess.Popen([new_filename, "/VERYSILENT", "/SUPPRESSMSGBOXES", "/SP-", "/CLOSEAPPLICATIONS", "/NORESTART"])
|
# Launch installer and exit — the installer will close this process,
|
||||||
while proc.poll() is None:
|
# install the update, and relaunch the app via its [Run] section.
|
||||||
QtWidgets.QApplication.processEvents()
|
subprocess.Popen([installer_path, "/VERYSILENT", "/SUPPRESSMSGBOXES", "/SP-", "/CLOSEAPPLICATIONS"])
|
||||||
import time
|
time.sleep(1)
|
||||||
time.sleep(0.1)
|
|
||||||
|
|
||||||
progress.close()
|
|
||||||
|
|
||||||
try:
|
|
||||||
os.remove(new_filename)
|
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
install_path = _find_install_path()
|
|
||||||
if not install_path:
|
|
||||||
raise FileNotFoundError("Could not find SoftwareManager install location in registry")
|
|
||||||
subprocess.Popen([os.path.join(install_path, "SoftwareManager.exe")])
|
|
||||||
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user