Skip to content

Commit

Permalink
suggest to update PySM 3 in case file not found
Browse files Browse the repository at this point in the history
See #164
  • Loading branch information
zonca committed Jun 9, 2023
1 parent bbfa529 commit 32a892c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pysm3/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from astropy.io import fits
from astropy.tests.helper import assert_quantity_allclose
from pysm3 import utils
from urllib.error import URLError


def test_get_relevant_frequencies():
Expand Down Expand Up @@ -148,3 +149,8 @@ def test_add_metadata_different_units(test_fits_file):
assert f[1].header["TUNIT2"] == "mK_RJ"
assert f[1].header["TUNIT3"] == "K_CMB"
assert f[1].header["REF_FREQ"] == "353 GHz"


def test_data_raise():
with pytest.raises(URLError):
pysm3.utils.RemoteData().get("doesntexist.txt")
10 changes: 9 additions & 1 deletion pysm3/utils/data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os
import logging
from urllib.error import URLError


from astropy.utils import data

Expand Down Expand Up @@ -46,5 +48,11 @@ def get(self, filename):
"remote_timeout", 90
):
log.info(f"Retrieve data for {filename} (if not cached already)")
full_path = data.get_pkg_data_filename(filename, show_progress=True)
try:
full_path = data.get_pkg_data_filename(filename, show_progress=True)
except URLError as e:
log.error(
"File not found, please make sure you are using the latest version of PySM 3"
)
raise e
return full_path

0 comments on commit 32a892c

Please sign in to comment.