From 717e7b68614cff28c94f30e3c74cab3583553674 Mon Sep 17 00:00:00 2001 From: jsbautista Date: Mon, 23 Dec 2024 11:22:47 -0500 Subject: [PATCH 1/5] Add catch and message to OSError --- spyder/plugins/updatemanager/workers.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/spyder/plugins/updatemanager/workers.py b/spyder/plugins/updatemanager/workers.py index c0781b7d4ef..fd0130310e4 100644 --- a/spyder/plugins/updatemanager/workers.py +++ b/spyder/plugins/updatemanager/workers.py @@ -22,7 +22,7 @@ from packaging.version import parse, Version from qtpy.QtCore import QObject, Signal import requests -from requests.exceptions import ConnectionError, HTTPError, SSLError +from requests.exceptions import ConnectionError, HTTPError, SSLError, OSError from spyder_kernels.utils.pythonenv import is_conda_env # Local imports @@ -50,7 +50,12 @@ 'SSL certificate verification failed while checking for Spyder updates.' '

Please contact your network administrator for assistance.' ) - +TLS_ERROR_MSG = _( + 'TLS certificate configuration error while checking for Spyder updates.' + '

Please verify that the TLS CA certificate bundle is correctly ' + 'configured. If you are using a custom Python environment, ' + 'ensure the certificate file path is valid and try again later.' +) def _rate_limits(page): """Log rate limits for GitHub.com""" @@ -294,6 +299,9 @@ def start(self): except HTTPError as err: error_msg = HTTP_ERROR_MSG.format(status_code=page.status_code) logger.warning(err, exc_info=err) + except OSError as err: + error_msg = TLS_ERROR_MSG + logger.warning(err, exc_info=err) except Exception as err: # Send untracked errors to our error reporter error_data = dict( From 06a47d5ca194fd72564109800d5d6c06e394a000 Mon Sep 17 00:00:00 2001 From: jsbautista Date: Mon, 30 Dec 2024 12:15:25 -0500 Subject: [PATCH 2/5] Add Checkbox to error message --- spyder/plugins/updatemanager/widgets/update.py | 10 +++++----- spyder/plugins/updatemanager/workers.py | 16 +++++++++------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/spyder/plugins/updatemanager/widgets/update.py b/spyder/plugins/updatemanager/widgets/update.py index 3cc7b7f7020..c092214b4d5 100644 --- a/spyder/plugins/updatemanager/widgets/update.py +++ b/spyder/plugins/updatemanager/widgets/update.py @@ -228,6 +228,7 @@ def _process_check_update(self): # Get results from worker update_available = self.update_worker.update_available error_msg = self.update_worker.error + checkbox = self.update_worker.checkbox # Always set status, regardless of error, DEV, or startup self.set_status(PENDING if update_available else NO_STATUS) @@ -243,7 +244,7 @@ def _process_check_update(self): # Do not alert the user to anything pass elif error_msg is not None: - error_messagebox(self, error_msg) + error_messagebox(self, error_msg, checkbox) elif update_available: self.start_update() else: @@ -532,10 +533,9 @@ def update_progress(self, progress, total): self._progress_bar.setValue(progress) -def error_messagebox(parent, error_msg): - box = UpdateMessageBox( - icon=QMessageBox.Warning, text=error_msg, parent=parent - ) +def error_messagebox(parent, error_msg, checkbox=False): + box_class = UpdateMessageCheckBox if checkbox else UpdateMessageBox + box = box_class(icon=QMessageBox.Warning, text=error_msg, parent=parent) box.setWindowTitle(_("Spyder update error")) box.setStandardButtons(QMessageBox.Ok) box.setDefaultButton(QMessageBox.Ok) diff --git a/spyder/plugins/updatemanager/workers.py b/spyder/plugins/updatemanager/workers.py index fd0130310e4..787643455d8 100644 --- a/spyder/plugins/updatemanager/workers.py +++ b/spyder/plugins/updatemanager/workers.py @@ -22,7 +22,7 @@ from packaging.version import parse, Version from qtpy.QtCore import QObject, Signal import requests -from requests.exceptions import ConnectionError, HTTPError, SSLError, OSError +from requests.exceptions import ConnectionError, HTTPError, SSLError from spyder_kernels.utils.pythonenv import is_conda_env # Local imports @@ -50,11 +50,11 @@ 'SSL certificate verification failed while checking for Spyder updates.' '

Please contact your network administrator for assistance.' ) -TLS_ERROR_MSG = _( - 'TLS certificate configuration error while checking for Spyder updates.' - '

Please verify that the TLS CA certificate bundle is correctly ' - 'configured. If you are using a custom Python environment, ' - 'ensure the certificate file path is valid and try again later.' + +OS_ERROR_MSG = _( + 'An error occurred while checking for Spyder updates, possibly related to' + ' system configuration or file access.

Please verify your system ' + 'settings, including file paths and permissions.' ) def _rate_limits(page): @@ -195,6 +195,7 @@ def __init__(self, stable_only): self.latest_release = None self.update_available = False self.error = None + self.checkbox = False self.channel = None def _check_update_available( @@ -300,7 +301,8 @@ def start(self): error_msg = HTTP_ERROR_MSG.format(status_code=page.status_code) logger.warning(err, exc_info=err) except OSError as err: - error_msg = TLS_ERROR_MSG + error_msg = OS_ERROR_MSG + self.checkbox = True logger.warning(err, exc_info=err) except Exception as err: # Send untracked errors to our error reporter From 5806b430932f85f8a0b9d3dae104377ea8cc064e Mon Sep 17 00:00:00 2001 From: jsbautista Date: Mon, 13 Jan 2025 08:26:06 -0500 Subject: [PATCH 3/5] add comment --- spyder/plugins/updatemanager/widgets/update.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spyder/plugins/updatemanager/widgets/update.py b/spyder/plugins/updatemanager/widgets/update.py index c092214b4d5..36b6f04975e 100644 --- a/spyder/plugins/updatemanager/widgets/update.py +++ b/spyder/plugins/updatemanager/widgets/update.py @@ -534,6 +534,8 @@ def update_progress(self, progress, total): def error_messagebox(parent, error_msg, checkbox=False): + # Use a message box with a checkbox for enabling update checks, + # or a standard one otherwise. box_class = UpdateMessageCheckBox if checkbox else UpdateMessageBox box = box_class(icon=QMessageBox.Warning, text=error_msg, parent=parent) box.setWindowTitle(_("Spyder update error")) From 21774bebd7a042225c1ef4e4ef7087c9a52c1267 Mon Sep 17 00:00:00 2001 From: jsbautista Date: Tue, 14 Jan 2025 13:48:27 -0500 Subject: [PATCH 4/5] Apply suggestions --- spyder/plugins/updatemanager/widgets/update.py | 4 ++-- spyder/plugins/updatemanager/workers.py | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/spyder/plugins/updatemanager/widgets/update.py b/spyder/plugins/updatemanager/widgets/update.py index 36b6f04975e..5322b3028c5 100644 --- a/spyder/plugins/updatemanager/widgets/update.py +++ b/spyder/plugins/updatemanager/widgets/update.py @@ -534,8 +534,8 @@ def update_progress(self, progress, total): def error_messagebox(parent, error_msg, checkbox=False): - # Use a message box with a checkbox for enabling update checks, - # or a standard one otherwise. + # Use a message box with a checkbox to disable updates when required, or a + # standard one otherwise. box_class = UpdateMessageCheckBox if checkbox else UpdateMessageBox box = box_class(icon=QMessageBox.Warning, text=error_msg, parent=parent) box.setWindowTitle(_("Spyder update error")) diff --git a/spyder/plugins/updatemanager/workers.py b/spyder/plugins/updatemanager/workers.py index 787643455d8..fcf9381542c 100644 --- a/spyder/plugins/updatemanager/workers.py +++ b/spyder/plugins/updatemanager/workers.py @@ -52,9 +52,10 @@ ) OS_ERROR_MSG = _( - 'An error occurred while checking for Spyder updates, possibly related to' - ' system configuration or file access.

Please verify your system ' - 'settings, including file paths and permissions.' + "An error occurred while checking for Spyder updates, possibly related to " + "your operating system configuration or file access.

If you're not " + "sure what to do about it, you can disable checking for updates below. " + "

The error was:

{error}" ) def _rate_limits(page): @@ -301,7 +302,7 @@ def start(self): error_msg = HTTP_ERROR_MSG.format(status_code=page.status_code) logger.warning(err, exc_info=err) except OSError as err: - error_msg = OS_ERROR_MSG + error_msg = OS_ERROR_MSG.format(error=err) self.checkbox = True logger.warning(err, exc_info=err) except Exception as err: From afccd8d924f3bd2defe692c04617f6283ca02486 Mon Sep 17 00:00:00 2001 From: jsbautista <42411448+jsbautista@users.noreply.github.com> Date: Wed, 15 Jan 2025 14:45:18 -0500 Subject: [PATCH 5/5] Update spyder/plugins/updatemanager/workers.py Co-authored-by: Carlos Cordoba --- spyder/plugins/updatemanager/workers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spyder/plugins/updatemanager/workers.py b/spyder/plugins/updatemanager/workers.py index fcf9381542c..01e4f5b0d5d 100644 --- a/spyder/plugins/updatemanager/workers.py +++ b/spyder/plugins/updatemanager/workers.py @@ -55,7 +55,7 @@ "An error occurred while checking for Spyder updates, possibly related to " "your operating system configuration or file access.

If you're not " "sure what to do about it, you can disable checking for updates below. " - "

The error was:

{error}" + "

The error was:

{error}" ) def _rate_limits(page):