mirror of
https://github.com/chidiwilliams/buzz.git
synced 2026-03-14 14:45:46 +01:00
Cleanup
This commit is contained in:
parent
ff3972d135
commit
3f5b3941f6
2 changed files with 7 additions and 30 deletions
|
|
@ -1,8 +1,8 @@
|
|||
import json
|
||||
import logging
|
||||
import platform
|
||||
from datetime import datetime, timedelta
|
||||
from typing import Optional, Callable
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
from dataclasses import dataclass
|
||||
|
||||
from PyQt6.QtCore import QObject, pyqtSignal, QUrl
|
||||
|
|
@ -44,7 +44,7 @@ class UpdateChecker(QObject):
|
|||
self.network_manager.finished.connect(self._on_reply_finished)
|
||||
|
||||
def should_check_for_updates(self) -> bool:
|
||||
""""Check if we are on Windows/macOS and if 7 days passed"""
|
||||
"""Check if we are on Windows/macOS and if 7 days passed"""
|
||||
system = platform.system()
|
||||
if system not in ("Windows", "Darwin"):
|
||||
logging.debug("Skipping update check on linux")
|
||||
|
|
@ -168,8 +168,4 @@ class UpdateChecker(QObject):
|
|||
|
||||
except ValueError:
|
||||
logging.error(f"Invalid version format: {VERSION} or {remote_version}")
|
||||
return False
|
||||
|
||||
|
||||
|
||||
|
||||
return False
|
||||
|
|
@ -47,7 +47,6 @@ class UpdateDialog(QDialog):
|
|||
|
||||
self._setup_ui()
|
||||
|
||||
|
||||
def _setup_ui(self):
|
||||
self.setWindowTitle(_("Update Available"))
|
||||
self.setWindowIcon(QIcon(BUZZ_ICON_PATH))
|
||||
|
|
@ -72,7 +71,6 @@ class UpdateDialog(QDialog):
|
|||
|
||||
new_version_label = QLabel(_("New version:"))
|
||||
new_version_value = QLabel(f"<b>{self.update_info.version}</b>")
|
||||
new_version_value.setStyleSheet("color: green;")
|
||||
|
||||
version_layout.addWidget(current_version_label)
|
||||
version_layout.addWidget(current_version_value)
|
||||
|
|
@ -237,7 +235,6 @@ class UpdateDialog(QDialog):
|
|||
self.status_label.setText(_("Download complete!"))
|
||||
self._run_installer()
|
||||
|
||||
|
||||
def _run_installer(self):
|
||||
"""Run the downloaded installer"""
|
||||
if not self._temp_file_paths:
|
||||
|
|
@ -248,21 +245,14 @@ class UpdateDialog(QDialog):
|
|||
|
||||
try:
|
||||
if system == "Windows":
|
||||
self.status_label.setText(_("Launching installer..."))
|
||||
subprocess.Popen([installer_path], shell=True)
|
||||
self.accept()
|
||||
|
||||
elif system == "Darwin":
|
||||
#open the DMG file
|
||||
self.status_label.setText(_("Opening disk image..."))
|
||||
subprocess.Popen(["open", installer_path])
|
||||
|
||||
QMessageBox.information(
|
||||
self,
|
||||
_("Install Update"),
|
||||
_("The disk image has been opened. Please drag Buzz to your Applications folder to complete the update.")
|
||||
)
|
||||
self.accept()
|
||||
# Close update dialog
|
||||
self.accept()
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"Failed to run installer: {e}")
|
||||
|
|
@ -272,7 +262,6 @@ class UpdateDialog(QDialog):
|
|||
_("Failed to run the installer: {}").format(str(e))
|
||||
)
|
||||
|
||||
|
||||
def _reset_ui(self):
|
||||
"""Reset the UI to initial state after an error"""
|
||||
self.download_button.setEnabled(True)
|
||||
|
|
@ -280,7 +269,6 @@ class UpdateDialog(QDialog):
|
|||
self.progress_bar.setVisible(False)
|
||||
self.status_label.setText("")
|
||||
|
||||
|
||||
def reject(self):
|
||||
"""Cancel download in progress when user clicks Cancel or Later"""
|
||||
if self._download_reply is not None:
|
||||
|
|
@ -288,11 +276,4 @@ class UpdateDialog(QDialog):
|
|||
self._download_reply.deleteLater()
|
||||
self._download_reply = None
|
||||
|
||||
super().reject()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
super().reject()
|
||||
Loading…
Add table
Add a link
Reference in a new issue