From 0f21b25fa4c8f0c29d39d4892f1c2cf9f6c085a7 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 27 Apr 2025 18:55:29 +0100 Subject: [PATCH] fixed connection type exception --- gui/__main__.py | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/gui/__main__.py b/gui/__main__.py index e564fc8..749f965 100644 --- a/gui/__main__.py +++ b/gui/__main__.py @@ -79,10 +79,6 @@ class WorkerThread(QThread): self.disable_profile() elif self.action == 'SYNC' or self.action == 'SYNC_TOR': self.sync() - elif self.action == 'GET_CONNECTION': - self.get_connection() - elif self.action == 'SET_CONNECTION': - self.set_connection() elif self.action == 'DESTROY_PROFILE': self.destroy_profile() elif self.action == 'DISABLE_ALL_PROFILES': @@ -119,7 +115,6 @@ class WorkerThread(QThread): client_observer.subscribe('updated', lambda event: self.text_output.emit("Update process completed")) - def check_for_update(self): self.text_output.emit("Checking for updates...") ClientController.sync(client_observer=client_observer, connection_observer=connection_observer) @@ -299,6 +294,7 @@ class WorkerThread(QThread): class CustomWindow(QMainWindow): def __init__(self): super().__init__() + sys.excepthook = self._handle_exception self.setWindowFlags( Qt.WindowType.Window ) @@ -326,8 +322,9 @@ class CustomWindow(QMainWindow): self.current_profile_id = None self.connection_manager = ConnectionManager() - current_connection = 'system' #For Default toggle behavior + current_connection = None self.is_tor_mode = current_connection == 'tor' + self.is_animating = False self.animation_step = 0 self.page_history = [] @@ -410,12 +407,32 @@ class CustomWindow(QMainWindow): self.set_toggle_state(self.is_tor_mode) - def get_current_connection(self): - try: - return ConfigurationController.get_connection() - except UnknownConnectionTypeError: + + + + def _handle_exception(self, identifier, message, trace): + if issubclass(identifier, UnknownConnectionTypeError): self.setup_popup() + os.execv(sys.executable, [sys.executable] + sys.argv) + + else: + + config = self._load_gui_config() + + if config and config["logging"]["gui_logging_enabled"] == True: + + logging.error( + f"Uncaught exception:\n" + f"Type: {identifier.__name__}\n" + f"Value: {str(message)}\n" + f"Traceback:\n{''.join(traceback.format_tb(trace))}" + ) + + sys.__excepthook__(identifier, message, trace) + + def get_current_connection(self): return ConfigurationController.get_connection() + def setup_popup(self): connection_dialog = QDialog(self) @@ -844,14 +861,6 @@ class CustomWindow(QMainWindow): self.disable_marquee() return - if is_downloading and not self.is_downloading: - self.is_downloading = True - - if self.is_downloading and 'Downloading' not in text: - return - - if 'Downloaded' in text: - self.is_downloading = False if clear: self.status_label.setText('') @@ -4978,6 +4987,7 @@ class PaymentPage(Page): self.on_request_invoice() def on_request_invoice(self): + raise UnknownConnectionTypeError('The connection type is unknown') total_hours = self.fetch_invoice_duration() selected_currency = self.get_selected_currency() if selected_currency is None: