Skip to content

Commit

Permalink
Merge pull request #1610 from djhoese/bugfix-aux-download-script
Browse files Browse the repository at this point in the history
Fix auxiliary download script not using provided data directory
  • Loading branch information
mraspaud committed Mar 22, 2021
2 parents 88f0dcb + 1b2aae7 commit 3623c03
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
6 changes: 3 additions & 3 deletions satpy/aux_download.py
Expand Up @@ -333,7 +333,7 @@ def _register_data_file(data_file_entry, comp_type):
known_hash=known_hash)


def retrieve_all_cmd():
def retrieve_all_cmd(argv=None):
"""Call 'retrieve_all' function from console script 'satpy_retrieve_all'."""
import argparse
parser = argparse.ArgumentParser(description="Download auxiliary data files used by Satpy.")
Expand All @@ -354,13 +354,13 @@ def retrieve_all_cmd():
help="Limit searching to these writers. If specified "
"with no arguments, no writer files will be "
"downloaded.")
args = parser.parse_args()
args = parser.parse_args(argv)

logging.basicConfig(level=logging.INFO)

if args.data_dir is None:
args.data_dir = satpy.config.get('data_dir')

with satpy.config.set(datA_dir=args.data_dir):
with satpy.config.set(data_dir=args.data_dir):
retrieve_all(readers=args.readers, writers=args.writers,
composite_sensors=args.composite_sensors)
17 changes: 17 additions & 0 deletions satpy/tests/test_data_download.py
Expand Up @@ -229,3 +229,20 @@ def test_no_downloads_in_tests(self):
# offline downloading should still be allowed
with satpy.config.set(download_aux=False):
retrieve(cache_key)

def test_download_script(self):
"""Test basic functionality of the download script."""
from satpy.aux_download import retrieve_all_cmd
import satpy
file_registry = {}
file_urls = {}
with satpy.config.set(config_path=[self.tmpdir]), \
mock.patch('satpy.aux_download._FILE_REGISTRY', file_registry), \
mock.patch('satpy.aux_download._FILE_URLS', file_urls), \
mock.patch('satpy.aux_download.find_registerable_files'):
comp_file = 'composites/README.rst'
file_registry[comp_file] = None
file_urls[comp_file] = README_URL
assert not self.tmpdir.join(comp_file).exists()
retrieve_all_cmd(argv=["--data-dir", str(self.tmpdir)])
assert self.tmpdir.join(comp_file).exists()

0 comments on commit 3623c03

Please sign in to comment.