Skip to content

Commit

Permalink
Improve user feedback during updater
Browse files Browse the repository at this point in the history
  • Loading branch information
jfeil committed May 13, 2022
1 parent e6caddf commit 74c991b
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import markdown2
import requests
from PySide6.QtCore import Signal, QThread, Qt
from PySide6.QtWidgets import QDialog
from PySide6.QtWidgets import QDialog, QMessageBox

from src.basic_config import app_dirs, current_platform, base_path, is_bundled
from src.ui_update_checker import Ui_UpdateChecker
Expand Down Expand Up @@ -39,7 +39,6 @@ def __init__(self, parent, versions, display_dev=False):
self.ui.install_update_button.setText("Auto-Update ist nur mit der kompilierten Version möglich!")
if current_platform == 'Darwin':
self.ui.install_update_button.setVisible(False)

self.display()

def display(self):
Expand All @@ -66,11 +65,7 @@ def display(self):
f'{release_notes}{download_link}')

def update(self) -> None:
def progressbar_tracking(value):
self.ui.download_progress.setValue(value)
if value != 100:
return

def install_update():
updater_script_unix = "updater.sh"
os.rename(os.path.join(base_path, updater_script_unix),
os.path.join(app_dirs.user_cache_dir, updater_script_unix))
Expand All @@ -91,6 +86,19 @@ def progressbar_tracking(value):
sys.executable, str(os.getpid()), download_path]), shell=True)
sys.exit(0)

def progressbar_tracking(value):
self.ui.download_progress.setValue(value)
if value != 100:
return

info_box = QMessageBox(self)
info_box.setWindowTitle("Update erfolgreich heruntergeladen!")
info_box.setText("Die Installation dauert ca. 15 Sekunden.")
info_box.setInformativeText("Dabei wird die Applikation beendet und nach "
"erfolgreichem Update erneut gestartet.")
info_box.exec()
install_update()

if not self.download_link:
return

Expand All @@ -112,10 +120,6 @@ def progressbar_tracking(value):
downloadThread.download_progress.connect(progressbar_tracking)
downloadThread.run()

# r = requests.get(self.download_link)
# with open(download_path, 'wb+') as file:
# file.write(r.content)


class DownloadThread(QThread):
download_progress = Signal(int)
Expand Down

0 comments on commit 74c991b

Please sign in to comment.