def env(ctx, key): """Print information about the Rasterio environment.""" with ctx.obj['env'] as env: if key == 'formats': for k, v in sorted(env.drivers().items()): click.echo("{0}: {1}".format(k, v)) elif key == 'credentials': click.echo(json.dumps(env.session.credentials)) elif key == 'gdal_data': click.echo( os.environ.get('GDAL_DATA') or GDALDataFinder().search()) elif key == 'proj_data': click.echo(os.environ.get('PROJ_LIB') or PROJDataFinder().search())
def test_search_prefix_gdal_data_failure(tmpdir): """Fail to find GDAL data in a bogus prefix""" finder = GDALDataFinder() assert not finder.search_prefix(str(tmpdir))
def test_search_wheel_gdal_data(mock_wheel): """Find GDAL data in a wheel""" finder = GDALDataFinder() assert finder.search_wheel(str(mock_wheel.join("_env.py"))) == str( mock_wheel.join("gdal_data"))
def test_search_wheel_gdal_data_failure(tmpdir): """Fail to find GDAL data in a non-wheel""" finder = GDALDataFinder() assert not finder.search_wheel(str(tmpdir))
param, full_kwds[param], inequality, version, reason)) return f(*args, **kwds) return wrapper return decorator # Patch the environment if needed, such as in the installed wheel case. if 'GDAL_DATA' not in os.environ: path = GDALDataFinder().search_wheel() if path: os.environ['GDAL_DATA'] = path log.debug("GDAL data found in package, GDAL_DATA set to %r.", path) # See https://github.com/mapbox/rasterio/issues/1631. elif GDALDataFinder().find_file("header.dxf"): log.debug("GDAL data files are available at built-in paths") else: path = GDALDataFinder().search() if path: os.environ['GDAL_DATA'] = path log.debug("GDAL_DATA not found in environment, set to %r.", path)
raise GDALVersionError('parameter "{0}={1}" requires ' 'GDAL {2} {3}{4}'.format( param, full_kwds[param], inequality, version, reason)) return f(*args, **kwds) return wrapper return decorator # Patch the environment if needed, such as in the installed wheel case. if 'GDAL_DATA' not in os.environ: path = GDALDataFinder().search() if path: os.environ['GDAL_DATA'] = path log.debug("GDAL_DATA not found in environment, set to %r.", path) if 'PROJ_LIB' not in os.environ: path = PROJDataFinder().search() if path: os.environ['PROJ_LIB'] = path log.debug("PROJ data not found in environment, set to %r.", path)
def test_search_gdal_data_debian(mock_debian): """Find GDAL data under Debian locations""" finder = GDALDataFinder() assert finder.search(str(mock_debian)) == str( mock_debian.join("share").join("gdal").join("{}".format( str(gdal_version))))
def test_search_gdal_data_wheel(mock_wheel): finder = GDALDataFinder() assert finder.search(str(mock_wheel.join("_env.py"))) == str( mock_wheel.join("gdal_data"))
def test_search_gdal_data_wheel(mock_wheel): finder = GDALDataFinder() assert finder.search(str(mock_wheel.join("_env.py"))) == str(mock_wheel.join("gdal_data"))
def test_search_debian_gdal_data_failure(tmpdir): """Fail to find GDAL data in a bogus Debian location""" finder = GDALDataFinder() assert not finder.search_debian(str(tmpdir))
def test_search_prefix_gdal_data(mock_fhs): """Find GDAL data under prefix""" finder = GDALDataFinder() assert finder.search_prefix(str(mock_fhs)) == str(mock_fhs.join("share").join("gdal"))
def test_search_wheel_gdal_data(mock_wheel): """Find GDAL data in a wheel""" finder = GDALDataFinder() assert finder.search_wheel(str(mock_wheel.join("_env.py"))) == str(mock_wheel.join("gdal_data"))
def test_search_prefix_gdal_data(mock_fhs): """Find GDAL data under prefix""" finder = GDALDataFinder() assert finder.search_prefix(str(mock_fhs)) == str( mock_fhs.join("share").join("gdal"))
def test_search_gdal_data_fhs(mock_fhs): finder = GDALDataFinder() assert finder.search(str(mock_fhs)) == str(mock_fhs.join("share").join("gdal"))
def test_search_gdal_data_fhs(mock_fhs): finder = GDALDataFinder() assert finder.search(str(mock_fhs)) == str( mock_fhs.join("share").join("gdal"))
def test_search_gdal_data_debian(mock_debian): """Find GDAL data under Debian locations""" finder = GDALDataFinder() assert finder.search(str(mock_debian)) == str(mock_debian.join("share").join("gdal").join("{}".format(str(gdal_version))))
def test_gdal_data(): """Get GDAL data path from a wheel""" assert GDALDataFinder().search() == os.path.join( os.path.dirname(rasterio.__file__), 'gdal_data')
def test_gdal_data_find_file(): """Find_file shouldn't raise any exceptions""" GDALDataFinder().find_file("header.dxf")