示例#1
0
def test_vrt_shared_no_proxy_pool():

    before = gdaltest.get_opened_files()
    vrt_text = """<VRTDataset rasterXSize="50" rasterYSize="50">
  <VRTRasterBand dataType="Byte" band="1">
    <ColorInterp>Red</ColorInterp>
    <SimpleSource>
      <SourceFilename>data/rgbsmall.tif</SourceFilename>
      <SourceBand>1</SourceBand>
    </SimpleSource>
  </VRTRasterBand>
  <VRTRasterBand dataType="Byte" band="2">
    <ColorInterp>Green</ColorInterp>
    <SimpleSource>
      <SourceFilename>data/rgbsmall.tif</SourceFilename>
      <SourceBand>2</SourceBand>
    </SimpleSource>
  </VRTRasterBand>
  <VRTRasterBand dataType="Byte" band="3">
    <ColorInterp>Blue</ColorInterp>
    <SimpleSource>
      <SourceFilename>data/rgbsmall.tif</SourceFilename>
      <SourceBand>3</SourceBand>
    </SimpleSource>
  </VRTRasterBand>
</VRTDataset>"""
    ds = gdal.Open(vrt_text)
    assert ds
    assert ds.GetRasterBand(1).Checksum() == 21212
    assert ds.GetRasterBand(2).Checksum() == 21053
    assert ds.GetRasterBand(3).Checksum() == 21349
    ds = None

    after = gdaltest.get_opened_files()
    assert len(before) == len(after)
示例#2
0
def check_no_file_leaks():
    num_files = len(gdaltest.get_opened_files())

    yield

    diff = len(gdaltest.get_opened_files()) - num_files
    assert diff == 0, 'Leak of file handles: %d leaked' % diff
示例#3
0
文件: bag.py 项目: OSGeo/gdal
def check_no_file_leaks():
    num_files = len(gdaltest.get_opened_files())

    yield

    diff = len(gdaltest.get_opened_files()) - num_files
    assert diff == 0, 'Leak of file handles: %d leaked' % diff
示例#4
0
文件: vrt_read.py 项目: OSGeo/gdal
def test_vrt_shared_no_proxy_pool():

    before = gdaltest.get_opened_files()
    vrt_text = """<VRTDataset rasterXSize="50" rasterYSize="50">
  <VRTRasterBand dataType="Byte" band="1">
    <ColorInterp>Red</ColorInterp>
    <SimpleSource>
      <SourceFilename>data/rgbsmall.tif</SourceFilename>
      <SourceBand>1</SourceBand>
    </SimpleSource>
  </VRTRasterBand>
  <VRTRasterBand dataType="Byte" band="2">
    <ColorInterp>Green</ColorInterp>
    <SimpleSource>
      <SourceFilename>data/rgbsmall.tif</SourceFilename>
      <SourceBand>2</SourceBand>
    </SimpleSource>
  </VRTRasterBand>
  <VRTRasterBand dataType="Byte" band="3">
    <ColorInterp>Blue</ColorInterp>
    <SimpleSource>
      <SourceFilename>data/rgbsmall.tif</SourceFilename>
      <SourceBand>3</SourceBand>
    </SimpleSource>
  </VRTRasterBand>
</VRTDataset>"""
    ds = gdal.Open(vrt_text)
    assert ds
    assert ds.GetRasterBand(1).Checksum() == 21212
    assert ds.GetRasterBand(2).Checksum() == 21053
    assert ds.GetRasterBand(3).Checksum() == 21349
    ds = None

    after = gdaltest.get_opened_files()
    assert len(before) == len(after)
示例#5
0
def check_no_file_leaks():
    num_files = len(gdaltest.get_opened_files())

    yield

    diff = len(gdaltest.get_opened_files()) - num_files

    if diff != 0 and gdaltest.is_travis_branch('ubuntu_1804'):
        print('Mysterious leak of file handle on ubuntu_1804')
        return

    assert diff == 0, 'Leak of file handles: %d leaked' % diff
示例#6
0
def check_no_file_leaks():
    num_files = len(gdaltest.get_opened_files())

    yield

    diff = len(gdaltest.get_opened_files()) - num_files

    if diff != 0 and (gdaltest.is_travis_branch('ubuntu_1804')
                      or gdaltest.is_travis_branch('ubuntu_1804_32bit')
                      or gdaltest.is_travis_branch('fedora')
                      or gdaltest.is_travis_branch('alpine')):
        print('Mysterious leak of file handle on some CI setups')
        return

    assert diff == 0, 'Leak of file handles: %d leaked' % diff
示例#7
0
文件: bag.py 项目: zaviazhou/gdal
def bag_1():

    gdaltest.bag_drv = gdal.GetDriverByName('BAG')
    if gdaltest.bag_drv is None:
        return 'skip'

    gdaltest.count_opened_files = len(gdaltest.get_opened_files())

    return 'success'
示例#8
0
文件: hdf5.py 项目: hdfeos/gdal
def hdf5_1():

    gdaltest.hdf5_drv = gdal.GetDriverByName('HDF5')
    if gdaltest.hdf5_drv is None:
        return 'skip'

    gdaltest.count_opened_files = len(gdaltest.get_opened_files())

    return 'success'
示例#9
0
文件: hdf5.py 项目: zaviazhou/gdal
def hdf5_1():

    gdaltest.hdf5_drv = gdal.GetDriverByName('HDF5')
    if gdaltest.hdf5_drv is None:
        return 'skip'

    gdaltest.count_opened_files = len(gdaltest.get_opened_files())

    return 'success'
示例#10
0
文件: bag.py 项目: hdfeos/gdal
def bag_1():

    gdaltest.bag_drv = gdal.GetDriverByName('BAG')
    if gdaltest.bag_drv is None:
        return 'skip'

    gdaltest.count_opened_files = len(gdaltest.get_opened_files())

    return 'success'
示例#11
0
文件: vrt_read.py 项目: zq08/gdal
def test_vrt_shared_no_proxy_pool():

    before = gdaltest.get_opened_files()
    vrt_text = """<VRTDataset rasterXSize="50" rasterYSize="50">
  <VRTRasterBand dataType="Byte" band="1">
    <ColorInterp>Red</ColorInterp>
    <SimpleSource>
      <SourceFilename>data/rgbsmall.tif</SourceFilename>
      <SourceBand>1</SourceBand>
    </SimpleSource>
  </VRTRasterBand>
  <VRTRasterBand dataType="Byte" band="2">
    <ColorInterp>Green</ColorInterp>
    <SimpleSource>
      <SourceFilename>data/rgbsmall.tif</SourceFilename>
      <SourceBand>2</SourceBand>
    </SimpleSource>
  </VRTRasterBand>
  <VRTRasterBand dataType="Byte" band="3">
    <ColorInterp>Blue</ColorInterp>
    <SimpleSource>
      <SourceFilename>data/rgbsmall.tif</SourceFilename>
      <SourceBand>3</SourceBand>
    </SimpleSource>
  </VRTRasterBand>
</VRTDataset>"""
    ds = gdal.Open(vrt_text)
    assert ds
    assert ds.GetRasterBand(1).Checksum() == 21212
    assert ds.GetRasterBand(2).Checksum() == 21053
    assert ds.GetRasterBand(3).Checksum() == 21349
    ds = None

    after = gdaltest.get_opened_files()

    if len(before) != len(after) and (
            gdaltest.is_travis_branch('trusty_clang')
            or gdaltest.is_travis_branch('trusty_32bit')
            or gdaltest.is_travis_branch('ubuntu_1604')):
        pytest.xfail('Mysterious failure')

    assert len(before) == len(after)
示例#12
0
文件: bag.py 项目: zaviazhou/gdal
def bag_postcheck():

    if gdaltest.bag_drv is None:
        return 'skip'

    diff = len(gdaltest.get_opened_files()) - gdaltest.count_opened_files
    if diff != 0:
        gdaltest.post_reason('Leak of file handles: %d leaked' % diff)
        return 'fail'

    return 'success'
示例#13
0
文件: bag.py 项目: hdfeos/gdal
def bag_postcheck():

    if gdaltest.bag_drv is None:
        return 'skip'

    diff = len(gdaltest.get_opened_files()) - gdaltest.count_opened_files
    if diff != 0:
        gdaltest.post_reason('Leak of file handles: %d leaked' % diff)
        return 'fail'

    return 'success'
示例#14
0
def test_vrt_read_29():

    f = open('data/byte.tif')
    lst_before = sorted(gdaltest.get_opened_files())
    if not lst_before:
        pytest.skip()
    f.close()

    gdal.Translate('tmp/vrt_read_29.tif', 'data/byte.tif')

    vrt_text = """<VRTDataset rasterXSize="20" rasterYSize="20">
    <VRTRasterBand dataType="Byte" band="1">
        <SimpleSource>
        <SourceFilename>tmp/vrt_read_29.tif</SourceFilename>
        <SourceBand>1</SourceBand>
        <SourceProperties RasterXSize="20" RasterYSize="20" DataType="Byte" BlockXSize="20" BlockYSize="20" />
        <SrcRect xOff="0" yOff="0" xSize="20" ySize="20" />
        <DstRect xOff="0" yOff="0" xSize="20" ySize="20" />
        </SimpleSource>
    </VRTRasterBand>
    <VRTRasterBand dataType="Byte" band="2">
        <SimpleSource>
        <SourceFilename>tmp/vrt_read_29.tif</SourceFilename>
        <SourceBand>1</SourceBand>
        <SourceProperties RasterXSize="20" RasterYSize="20" DataType="Byte" BlockXSize="20" BlockYSize="20" />
        <SrcRect xOff="0" yOff="0" xSize="20" ySize="20" />
        <DstRect xOff="0" yOff="0" xSize="20" ySize="20" />
        </SimpleSource>
    </VRTRasterBand>
    </VRTDataset>"""

    lst_before = sorted(gdaltest.get_opened_files())
    ds = gdal.Open(vrt_text)
    # Just after opening, we shouldn't have read the source
    lst = sorted(gdaltest.get_opened_files())
    assert lst == lst_before

    # Check that the 2 bands share the same source handle
    ds.GetRasterBand(1).Checksum()
    lst = sorted(gdaltest.get_opened_files())
    assert len(lst) == len(lst_before) + 1
    ds.GetRasterBand(2).Checksum()
    lst = sorted(gdaltest.get_opened_files())
    assert len(lst) == len(lst_before) + 1

    # Open a second VRT dataset handle
    ds2 = gdal.Open(vrt_text)

    # Check that it consumes an extra handle
    ds2.GetRasterBand(1).Checksum()
    lst = sorted(gdaltest.get_opened_files())
    assert len(lst) == len(lst_before) + 2

    gdal.Unlink('tmp/vrt_read_29.tif')
示例#15
0
def test_vrt_read_29():

    f = open('data/byte.tif')
    lst_before = sorted(gdaltest.get_opened_files())
    if not lst_before:
        pytest.skip()
    f.close()

    gdal.Translate('tmp/vrt_read_29.tif', 'data/byte.tif')

    vrt_text = """<VRTDataset rasterXSize="20" rasterYSize="20">
    <VRTRasterBand dataType="Byte" band="1">
        <SimpleSource>
        <SourceFilename>tmp/vrt_read_29.tif</SourceFilename>
        <SourceBand>1</SourceBand>
        <SourceProperties RasterXSize="20" RasterYSize="20" DataType="Byte" BlockXSize="20" BlockYSize="20" />
        <SrcRect xOff="0" yOff="0" xSize="20" ySize="20" />
        <DstRect xOff="0" yOff="0" xSize="20" ySize="20" />
        </SimpleSource>
    </VRTRasterBand>
    <VRTRasterBand dataType="Byte" band="2">
        <SimpleSource>
        <SourceFilename>tmp/vrt_read_29.tif</SourceFilename>
        <SourceBand>1</SourceBand>
        <SourceProperties RasterXSize="20" RasterYSize="20" DataType="Byte" BlockXSize="20" BlockYSize="20" />
        <SrcRect xOff="0" yOff="0" xSize="20" ySize="20" />
        <DstRect xOff="0" yOff="0" xSize="20" ySize="20" />
        </SimpleSource>
    </VRTRasterBand>
    </VRTDataset>"""

    lst_before = sorted(gdaltest.get_opened_files())
    ds = gdal.Open(vrt_text)
    # Just after opening, we shouldn't have read the source
    lst = sorted(gdaltest.get_opened_files())
    assert lst == lst_before

    # Check that the 2 bands share the same source handle
    ds.GetRasterBand(1).Checksum()
    lst = sorted(gdaltest.get_opened_files())
    assert len(lst) == len(lst_before) + 1
    ds.GetRasterBand(2).Checksum()
    lst = sorted(gdaltest.get_opened_files())
    assert len(lst) == len(lst_before) + 1

    # Open a second VRT dataset handle
    ds2 = gdal.Open(vrt_text)

    # Check that it consumes an extra handle
    ds2.GetRasterBand(1).Checksum()
    lst = sorted(gdaltest.get_opened_files())
    assert len(lst) == len(lst_before) + 2

    gdal.Unlink('tmp/vrt_read_29.tif')
示例#16
0
def vrt_read_29():

    f = open('data/byte.tif')
    lst_before = gdaltest.get_opened_files()
    if len(lst_before) == 0:
        return 'skip'
    f.close()
    lst_before = gdaltest.get_opened_files()

    gdal.Translate('tmp/vrt_read_29.tif', 'data/byte.tif')

    vrt_text = """<VRTDataset rasterXSize="20" rasterYSize="20">
    <VRTRasterBand dataType="Byte" band="1">
        <SimpleSource>
        <SourceFilename>tmp/vrt_read_29.tif</SourceFilename>
        <SourceBand>1</SourceBand>
        <SourceProperties RasterXSize="20" RasterYSize="20" DataType="Byte" BlockXSize="20" BlockYSize="20" />
        <SrcRect xOff="0" yOff="0" xSize="20" ySize="20" />
        <DstRect xOff="0" yOff="0" xSize="20" ySize="20" />
        </SimpleSource>
    </VRTRasterBand>
    <VRTRasterBand dataType="Byte" band="2">
        <SimpleSource>
        <SourceFilename>tmp/vrt_read_29.tif</SourceFilename>
        <SourceBand>1</SourceBand>
        <SourceProperties RasterXSize="20" RasterYSize="20" DataType="Byte" BlockXSize="20" BlockYSize="20" />
        <SrcRect xOff="0" yOff="0" xSize="20" ySize="20" />
        <DstRect xOff="0" yOff="0" xSize="20" ySize="20" />
        </SimpleSource>
    </VRTRasterBand>
    </VRTDataset>"""

    ds = gdal.Open(vrt_text)
    # Just after opening, we shouldn't have read the source
    lst = gdaltest.get_opened_files()
    if lst.sort() != lst_before.sort():
        gdaltest.post_reason('fail')
        print(lst)
        print(lst_before)
        return 'fail'

    # Check that the 2 bands share the same source handle
    ds.GetRasterBand(1).Checksum()
    lst = gdaltest.get_opened_files()
    if len(lst) != len(lst_before) + 1:
        gdaltest.post_reason('fail')
        print(lst)
        print(lst_before)
        return 'fail'
    ds.GetRasterBand(2).Checksum()
    lst = gdaltest.get_opened_files()
    if len(lst) != len(lst_before) + 1:
        gdaltest.post_reason('fail')
        print(lst)
        print(lst_before)
        return 'fail'

    # Open a second VRT dataset handle
    ds2 = gdal.Open(vrt_text)

    # Check that it consumes an extra handle
    ds2.GetRasterBand(1).Checksum()
    lst = gdaltest.get_opened_files()
    if len(lst) != len(lst_before) + 2:
        gdaltest.post_reason('fail')
        print(lst)
        print(lst_before)
        return 'fail'

    gdal.Unlink('tmp/vrt_read_29.tif')

    return 'success'
示例#17
0
文件: vrt_read.py 项目: jef-n/gdal
def vrt_read_29():

    f = open('data/byte.tif')
    lst_before = gdaltest.get_opened_files()
    if len(lst_before) == 0:
        return 'skip'
    f.close()
    lst_before = gdaltest.get_opened_files()

    gdal.Translate('tmp/vrt_read_29.tif', 'data/byte.tif')

    vrt_text = """<VRTDataset rasterXSize="20" rasterYSize="20">
    <VRTRasterBand dataType="Byte" band="1">
        <SimpleSource>
        <SourceFilename>tmp/vrt_read_29.tif</SourceFilename>
        <SourceBand>1</SourceBand>
        <SourceProperties RasterXSize="20" RasterYSize="20" DataType="Byte" BlockXSize="20" BlockYSize="20" />
        <SrcRect xOff="0" yOff="0" xSize="20" ySize="20" />
        <DstRect xOff="0" yOff="0" xSize="20" ySize="20" />
        </SimpleSource>
    </VRTRasterBand>
    <VRTRasterBand dataType="Byte" band="2">
        <SimpleSource>
        <SourceFilename>tmp/vrt_read_29.tif</SourceFilename>
        <SourceBand>1</SourceBand>
        <SourceProperties RasterXSize="20" RasterYSize="20" DataType="Byte" BlockXSize="20" BlockYSize="20" />
        <SrcRect xOff="0" yOff="0" xSize="20" ySize="20" />
        <DstRect xOff="0" yOff="0" xSize="20" ySize="20" />
        </SimpleSource>
    </VRTRasterBand>
    </VRTDataset>"""

    ds = gdal.Open(vrt_text)
    # Just after opening, we shouldn't have read the source
    lst = gdaltest.get_opened_files()
    if lst.sort() != lst_before.sort():
        gdaltest.post_reason('fail')
        print(lst)
        print(lst_before)
        return 'fail'

    # Check that the 2 bands share the same source handle
    ds.GetRasterBand(1).Checksum()
    lst = gdaltest.get_opened_files()
    if len(lst) != len(lst_before)+1:
        gdaltest.post_reason('fail')
        print(lst)
        print(lst_before)
        return 'fail'
    ds.GetRasterBand(2).Checksum()
    lst = gdaltest.get_opened_files()
    if len(lst) != len(lst_before)+1:
        gdaltest.post_reason('fail')
        print(lst)
        print(lst_before)
        return 'fail'

    # Open a second VRT dataset handle
    ds2 = gdal.Open(vrt_text)

    # Check that it consumes an extra handle
    ds2.GetRasterBand(1).Checksum()
    lst = gdaltest.get_opened_files()
    if len(lst) != len(lst_before)+2:
        gdaltest.post_reason('fail')
        print(lst)
        print(lst_before)
        return 'fail'

    gdal.Unlink('tmp/vrt_read_29.tif')

    return 'success'