From 4fa7e5f4d41450a4487d6f37207baeb280c92910 Mon Sep 17 00:00:00 2001
From: Ryan Clary <9618975+mrclary@users.noreply.github.com>
Date: Wed, 18 Oct 2023 13:54:08 -0700
Subject: [PATCH 1/3] Apply suggestions from code review.
---
spyder/workers/updates.py | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/spyder/workers/updates.py b/spyder/workers/updates.py
index 7c3fe1ae962..8dbd96c6f35 100644
--- a/spyder/workers/updates.py
+++ b/spyder/workers/updates.py
@@ -14,7 +14,7 @@
# Third party imports
from qtpy.QtCore import QObject, Signal
import requests
-from requests.adapters import ConnectionError, SSLError
+from requests.exceptions import ConnectionError, HTTPError, SSLError
# Local imports
from spyder import __version__
@@ -27,16 +27,21 @@
# Logger setup
logger = logging.getLogger(__name__)
+CONNECT_ERROR_MSG = _(
+ 'Unable to connect to the Spyder update service.'
+ '
Make sure the connection is working properly.'
+)
+
+HTTP_ERROR_MSG = _(
+ 'HTTP error {status_code} when checking for updates.'
+ '
Make sure your connection is working properly.'
+)
+
SSL_ERROR_MSG = _(
'SSL certificate verification failed while checking for Spyder updates.'
'
Please contact your network administrator for assistance.'
)
-CONNECT_ERROR_MSG = _(
- 'Unable to connect to the internet while checking for Spyder updates.'
- '
Make sure the connection is working properly.'
-)
-
class UpdateDownloadCancelledException(Exception):
"""Download for installer to update was cancelled."""
@@ -121,6 +126,7 @@ def start(self):
try:
logger.debug(f"Checking for updates from {self.url}")
page = requests.get(self.url)
+ page.raise_for_status()
data = page.json()
if is_pynsist() or running_in_mac_app():
@@ -146,6 +152,9 @@ def start(self):
except ConnectionError as err:
error_msg = CONNECT_ERROR_MSG
logger.debug(err, stack_info=True)
+ except HTTPError as err:
+ error_msg = HTTP_ERROR_MSG.format(page.status_code)
+ logger.debug(err, stack_info=True)
except Exception as err:
error = traceback.format_exc()
formatted_error = error.replace('\n', '
').replace(' ', ' ')
From dbeb733cad20baed069da4e3b2f55e0ec30562be Mon Sep 17 00:00:00 2001
From: Ryan Clary <9618975+mrclary@users.noreply.github.com>
Date: Wed, 18 Oct 2023 17:43:29 -0700
Subject: [PATCH 2/3] Apply suggestion from code review
Co-authored-by: Carlos Cordoba
---
spyder/workers/updates.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/spyder/workers/updates.py b/spyder/workers/updates.py
index 8dbd96c6f35..586c6cb41fa 100644
--- a/spyder/workers/updates.py
+++ b/spyder/workers/updates.py
@@ -29,7 +29,7 @@
CONNECT_ERROR_MSG = _(
'Unable to connect to the Spyder update service.'
- '
Make sure the connection is working properly.'
+ '
Make sure your connection is working properly.'
)
HTTP_ERROR_MSG = _(
From cfbdddce7a8042c9a3e1dff6c46457e16337fe97 Mon Sep 17 00:00:00 2001
From: Ryan Clary <9618975+mrclary@users.noreply.github.com>
Date: Thu, 19 Oct 2023 13:14:44 -0700
Subject: [PATCH 3/3] Apply suggestion from code review
Co-authored-by: C.A.M. Gerlach
---
spyder/workers/updates.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/spyder/workers/updates.py b/spyder/workers/updates.py
index 586c6cb41fa..2b1a914e7f0 100644
--- a/spyder/workers/updates.py
+++ b/spyder/workers/updates.py
@@ -34,7 +34,8 @@
HTTP_ERROR_MSG = _(
'HTTP error {status_code} when checking for updates.'
- '
Make sure your connection is working properly.'
+ '
Make sure your connection is working properly,'
+ 'and try again later.'
)
SSL_ERROR_MSG = _(