From f9b54ede8169ed8a85eabbe35d6e09d3baac6b46 Mon Sep 17 00:00:00 2001 From: Abdulqadir Ahmad <2004a3abuahmad@gmail.com> Date: Sat, 3 Jun 2023 00:39:42 +0100 Subject: [PATCH] fix updating while running from source if user checks for update from menu --- src/controller/mainController.py | 5 +++++ src/main.py | 2 +- src/update/updater.py | 3 +++ src/wxUI/commonMessageDialogs.py | 6 ++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/controller/mainController.py b/src/controller/mainController.py index 37518dc7..b191cc8c 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import os +import sys import logging import webbrowser import wx @@ -427,6 +428,10 @@ class Controller(object): return handler.account_settings(buffer=buffer, controller=self) def check_for_updates(self, *args, **kwargs): + if not getattr(sys, 'frozen', False): + log.debug("Running from source, can't update") + commonMessageDialogs.cant_update_source() + return update = updater.do_update() if update == False: view.no_update_available() diff --git a/src/main.py b/src/main.py index 1a5af71e..5610cd47 100644 --- a/src/main.py +++ b/src/main.py @@ -71,7 +71,7 @@ def setup(): check_pid() if config.app["app-settings"]["donation_dialog_displayed"] == False: donation() - if config.app['app-settings']['check_for_updates'] and getattr(sys, 'frozen', False): + if config.app['app-settings']['check_for_updates']: updater.do_update() sm = sessionManager.sessionManagerController() sm.fill_list() diff --git a/src/update/updater.py b/src/update/updater.py index 4e1b4046..99fedd19 100644 --- a/src/update/updater.py +++ b/src/update/updater.py @@ -8,6 +8,9 @@ from .wxUpdater import * logger = logging.getLogger("updater") def do_update(endpoint=application.update_url): + if not getattr(sys, 'frozen', False): + logger.debug("Running from source, aborting update check") + return False try: result = update.perform_update(endpoint=endpoint, current_version=application.version, app_name=application.name, update_available_callback=available_update_dialog, progress_callback=progress_callback, update_complete_callback=update_finished) except: diff --git a/src/wxUI/commonMessageDialogs.py b/src/wxUI/commonMessageDialogs.py index daa915eb..28e06a1b 100644 --- a/src/wxUI/commonMessageDialogs.py +++ b/src/wxUI/commonMessageDialogs.py @@ -38,3 +38,9 @@ def invalid_configuration(): def dead_pid(): return wx.MessageDialog(None, _(u"{0} quit unexpectedly the last time it was run. If the problem persists, please report it to the {0} developers.").format(application.name), _(u"Warning"), wx.OK).ShowModal() +def cant_update_source() -> wx.MessageDialog: + """Shows a dialog telling a user he /she can't update because he / she is + running from source + """ + dlg = wx.MessageDialog(None, _("Sorry, you can't update while running {} from source.").format(application.name), _("Error"), wx.OK) + return dlg.ShowModal()