예제 #1
0
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())
예제 #2
0
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))
예제 #3
0
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"))
예제 #4
0
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))
예제 #5
0
                                                   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)
예제 #6
0
파일: env.py 프로젝트: slc4bfhch/rasterio
                        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)
예제 #7
0
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))))
예제 #8
0
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"))
예제 #9
0
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"))
예제 #10
0
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))
예제 #11
0
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"))
예제 #12
0
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))
예제 #13
0
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"))
예제 #14
0
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))
예제 #15
0
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"))
예제 #16
0
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))
예제 #17
0
def test_search_gdal_data_fhs(mock_fhs):
    finder = GDALDataFinder()
    assert finder.search(str(mock_fhs)) == str(mock_fhs.join("share").join("gdal"))
예제 #18
0
def test_search_gdal_data_fhs(mock_fhs):
    finder = GDALDataFinder()
    assert finder.search(str(mock_fhs)) == str(
        mock_fhs.join("share").join("gdal"))
예제 #19
0
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))))
예제 #20
0
def test_gdal_data():
    """Get GDAL data path from a wheel"""
    assert GDALDataFinder().search() == os.path.join(
        os.path.dirname(rasterio.__file__), 'gdal_data')
예제 #21
0
def test_gdal_data_find_file():
    """Find_file shouldn't raise any exceptions"""
    GDALDataFinder().find_file("header.dxf")