Skip to content

Commit 279c683

Browse files
committed
Warn when flat=True and curl_flag=True
1 parent 9282366 commit 279c683

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

astroquery/mast/observations.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,8 @@ def _download_curl_script(self, products, out_dir):
648648
"""
649649

650650
url_list = [("uri", url) for url in products['dataURI']]
651-
download_file = "mastDownload_" + time.strftime("%Y%m%d%H%M%S")
652-
local_path = os.path.join(out_dir.rstrip('/'), download_file + ".sh")
651+
download_file = "mastDownload_" + time.strftime("%Y%m%d%H%M%S") + ".sh"
652+
local_path = os.path.join(out_dir, download_file)
653653

654654
response = self._download_file(self._portal_api_connection.MAST_BUNDLE_URL + ".sh",
655655
local_path, data=url_list, method="POST")
@@ -745,6 +745,9 @@ def download_products(self, products, *, download_dir=None, flat=False,
745745
download_dir = '.'
746746

747747
if curl_flag: # don't want to download the files now, just the curl script
748+
if flat:
749+
# flat=True doesn't work with curl_flag=True, so issue a warning
750+
warnings.warn("flat=True has no effect on curl downloads.", InputWarning)
748751
manifest = self._download_curl_script(products,
749752
download_dir)
750753

astroquery/mast/tests/test_mast_remote.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from astroquery import mast
1717

1818
from ..utils import ResolverError
19-
from ...exceptions import (InvalidQueryError, MaxResultsWarning, NoResultsWarning,
19+
from ...exceptions import (InputWarning, InvalidQueryError, MaxResultsWarning, NoResultsWarning,
2020
RemoteServiceError)
2121

2222

@@ -318,6 +318,19 @@ def test_observations_download_products_flat(self, tmp_path, msa_product_table):
318318

319319
assert Path(manifest["Local Path"][0]).parent == tmp_path
320320

321+
def test_observations_download_products_flat_curl(self, tmp_path, msa_product_table):
322+
323+
# Get a product list with 6 duplicate JWST MSA config files
324+
products = msa_product_table
325+
326+
assert len(products) == 6
327+
328+
# Download with flat=True, curl_flag=True, look for warning
329+
with pytest.warns(InputWarning):
330+
mast.Observations.download_products(products, flat=True,
331+
curl_flag=True,
332+
download_dir=tmp_path)
333+
321334
def test_observations_download_products_no_duplicates(self, tmp_path, caplog, msa_product_table):
322335

323336
# Get a product list with 6 duplicate JWST MSA config files

0 commit comments

Comments
 (0)