def ascii_dbase_root(tmpdir_factory): # If we already have a local copy, just return the path to that path = fiasco.defaults.get('test_ascii_dbase_root') if path is not None and os.path.exists(path): return path # Otherwise download the database path = tmpdir_factory.mktemp('chianti_dbase') download_dbase(CHIANTI_URL.format(version=LATEST_VERSION), path) return path
def ascii_dbase_root(tmpdir_factory, request): path = request.config.getoption('--ascii-dbase-root') if path is None: path = CHIANTI_URL.format(version=LATEST_VERSION) try: _ = urlopen(path) except ValueError: if not os.path.exists(path): raise ValueError(f'{path} is not a valid URL or file path') else: _path = request.config.getoption('--dbase-download-dir') if not _path: _path = tmpdir_factory.mktemp('chianti_dbase') download_dbase(path, _path) path = _path return path
ON_RTD = os.environ.get('READTHEDOCS') == 'True' ON_GHA = os.environ.get('CI') == 'true' # On Read the Docs and CI, download the database and build a minimal HDF5 version if ON_RTD or ON_GHA: from fiasco.util import download_dbase, build_hdf5_dbase from fiasco.util.setup_db import CHIANTI_URL, LATEST_VERSION if ON_RTD: os.environ['HOME'] = '/home/docs' # RTD does not set HOME? FIASCO_HOME = os.path.join(os.environ['HOME'], '.fiasco') if not os.path.exists(FIASCO_HOME): os.makedirs(FIASCO_HOME) ascii_dbase_root = os.path.join(FIASCO_HOME, 'chianti_dbase') hdf5_dbase_root = os.path.join(FIASCO_HOME, 'chianti_dbase.h5') download_dbase(CHIANTI_URL.format(version=LATEST_VERSION), ascii_dbase_root) build_hdf5_dbase(ascii_dbase_root, hdf5_dbase_root, files=[ 'chianti.ip', 'chianti.ioneq', 'sun_photospheric_1998_grevesse.abund', 'sun_coronal_1992_feldman.abund', 'c_1.diparams', 'c_2.diparams', 'c_2.drparams', 'c_2.rrparams', 'c_3.diparams', 'c_3.drparams', 'c_3.easplups', 'c_3.rrparams',