Exemplo n.º 1
0
def sqlmanager(tmp_path, downloader, sqlstorage, mocker):
    sqlmanager = DataManager(Cache(downloader, sqlstorage, tmp_path))
    sqlmanager._tempdir = str(tmp_path)
    m = mock.Mock()
    m.headers = {'Content-Disposition': 'test_file'}
    mocker.patch('sunpy.data.data_manager.cache.urlopen', return_value=m)
    yield sqlmanager
Exemplo n.º 2
0
def module_patched_manager(tmp_path, downloader, storage, mocker):
    def _get_module(func):
        return 'fake_module.'

    module_patched_manager = DataManager(Cache(downloader, storage, tmp_path))
    module_patched_manager._tempdir = str(tmp_path)
    module_patched_manager._get_module = _get_module
    m = mock.Mock()
    m.headers = {'Content-Disposition': 'test_file'}
    mocker.patch('sunpy.data.data_manager.cache.urlopen', return_value=m)
    yield module_patched_manager
Exemplo n.º 3
0
import astropy.units as u

import sunpy
from sunpy import config
from sunpy.data._sample import download_sample_data
from sunpy.data.data_manager.cache import Cache
from sunpy.data.data_manager.downloader import ParfiveDownloader
from sunpy.data.data_manager.manager import DataManager
from sunpy.data.data_manager.storage import SqliteStorage
from sunpy.util.config import CACHE_DIR

_download_dir = config.get('downloads', 'remote_data_manager_dir')

manager = DataManager(
    Cache(ParfiveDownloader(),
          SqliteStorage(_download_dir + '/data_manager.db'), _download_dir))
cache = Cache(ParfiveDownloader(),
              SqliteStorage(CACHE_DIR + '/cache.db'),
              CACHE_DIR,
              expiry=int(config.get('downloads', 'cache_expiry')) * u.day)

__all__ = ["download_sample_data", "manager", "cache"]