diff --git a/docs/change_history.rst b/docs/change_history.rst index 15dc44a5..f773a8b5 100644 --- a/docs/change_history.rst +++ b/docs/change_history.rst @@ -1,6 +1,19 @@ Change History ############## +.. _v1.3.7: + +V1.3.7 17-08-2023 +^^^^^^^^^^^^^^^^^ + +- Updated documentation theme to allow dark mode +- Removed python 3.6 and 3.8 from testing and added 3.9 and 3.10 +- Unfixed numpy version +- Removed testing with conda on github action because it only added complexity +- Added 3 seconds timeout to request to github to validate version and check if running version is latest +- Added correct exception handler in case the http request timed out. + + .. _v1.3.6: V1.3.6 25-03-2022 diff --git a/goodman_pipeline/core/check_version.py b/goodman_pipeline/core/check_version.py index 918f947c..275ec870 100644 --- a/goodman_pipeline/core/check_version.py +++ b/goodman_pipeline/core/check_version.py @@ -33,7 +33,7 @@ def get_last(github_api_token='GITHUB_ACCESS_TOKEN'): except KeyError: headers = {} - response = requests.get(API_URL, headers=headers) + response = requests.get(API_URL, headers=headers, timeout=3) if response.status_code != 200: # pragma: no cover raise ConnectionRefusedError('Number of tests reached maximum for now.') diff --git a/goodman_pipeline/core/core.py b/goodman_pipeline/core/core.py index 8abd6cbe..61c8ae35 100644 --- a/goodman_pipeline/core/core.py +++ b/goodman_pipeline/core/core.py @@ -17,6 +17,7 @@ import sys import time +import requests from astropy.utils import iers iers.Conf.iers_auto_url.set('ftp://cddis.gsfc.nasa.gov/pub/products/iers/finals2000A.all') from astroplan import Observer @@ -2958,7 +2959,11 @@ def setup_logging(debug=False, generic=False): # pragma: no cover log.info("Latest Release: {:s}".format(latest_release)) except ConnectionRefusedError: log.error('Unauthorized GitHub API Access reached maximum') - log.info("Current Version: {:s}".format(__version__)) + log.info(f"Current Version: {__version__}") + except requests.exceptions.ConnectionError: + log.warning("Unable to validate latest version. " + "The connection timed out or was not possible to establish") + log.info(f"Current Version: {__version__}") def trace(ccd, diff --git a/goodman_pipeline/core/tests/test_check_version.py b/goodman_pipeline/core/tests/test_check_version.py index 5bfbbd51..c3e32971 100644 --- a/goodman_pipeline/core/tests/test_check_version.py +++ b/goodman_pipeline/core/tests/test_check_version.py @@ -4,6 +4,8 @@ import os import unittest +import requests + from goodman_pipeline.core import check_version __version__ = __import__('goodman_pipeline').__version__ @@ -18,6 +20,8 @@ def test_get_last(self): # self.assertEqual(v, __version__) except ConnectionRefusedError: # pragma: no cover pass + except requests.exceptions.ConnectionError: # pragma: no cover + pass def test_get_last_no_token(self): try: @@ -26,14 +30,19 @@ def test_get_last_no_token(self): # self.assertEqual(v, __version__) except ConnectionRefusedError: # pragma: no cover pass + except requests.exceptions.ConnectionError: # pragma: no cover + pass except KeyError: # pragma: no cover pass def test_get_last_token(self): os.environ['FAKETOKEN'] = 'ThisIsNotARealToken' - self.assertRaises(ConnectionRefusedError, - check_version.get_last, - 'FAKETOKEN') + try: + self.assertRaises(ConnectionRefusedError, + check_version.get_last, + 'FAKETOKEN') + except requests.exceptions.ConnectionError: + pass def test_am_i_updated(self): @@ -42,3 +51,5 @@ def test_am_i_updated(self): self.assertFalse(check_version.am_i_updated('v0.0.0')) except ConnectionRefusedError: # pragma: no cover pass + except requests.exceptions.ConnectionError: # pragma: no cover + pass diff --git a/setup.cfg b/setup.cfg index 9a483293..ad69c0f6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -32,4 +32,4 @@ install_requires = ccdproc astroplan # version should be PEP440 compatible (http://www.python.org/dev/peps/pep-0440) -version = 1.3.6 +version = 1.3.7