Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suggest to update PySM 3 in case file not found #165

Merged
merged 1 commit into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading