def test_gdal_ls_py_8(): if not gdaltest.run_slow_tests(): return 'skip' try: drv = gdal.GetDriverByName( 'HTTP' ) except: drv = None if drv is None: return 'skip' f = gdal.VSIFOpenL('/vsicurl/http://svn.osgeo.org/gdal/trunk/autotest/ogr/data/poly.zip', 'rb') if f is None: return 'skip' gdal.VSIFCloseL(f) (ret, ret_str) = run_gdal_ls(['', '-l', '-R', '-Rzip', 'ftp://ftp.remotesensing.org/gdal/data/aig']) if ret != 'success': return ret if ret_str.find('-r--r--r-- 1 unknown unknown 24576 2007-03-29 00:00 /vsicurl/ftp://ftp.remotesensing.org/gdal/data/aig/nzdem/info/arc0002r.001') == -1: print(ret_str) return 'fail' if ret_str.find('-r--r--r-- 1 unknown unknown 24576 2007-03-29 12:20 /vsizip//vsicurl/ftp://ftp.remotesensing.org/gdal/data/aig/nzdem.zip/nzdem/info/arc0002r.001') == -1: print(ret_str) return 'fail' return 'success'
def vsicurl_11(): if not gdaltest.run_slow_tests(): return 'skip' try: drv = gdal.GetDriverByName('HTTP') except: drv = None if drv is None: return 'skip' f = gdal.VSIFOpenL( '/vsicurl/http://download.osgeo.org/gdal/data/bmp/Bug2236.bmp', 'rb') if f is None: return 'skip' gdal.VSIFSeekL(f, 1000000, 0) gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) filelist = gdal.ReadDir( '/vsicurl/http://download.osgeo.org/gdal/data/gtiff') if filelist is None or len(filelist) == 0: return 'fail' return 'success'
def test_vsizip_create_zip64_stream_larger_than_4G(): if not gdaltest.run_slow_tests(): pytest.skip() zip_name = 'tmp/vsizip_create_zip64_stream_larger_than_4G.zip' gdal.Unlink(zip_name) niters = 999 s = ''.join([chr(random.randint(0, 127)) for i in range(5 * 1000 * 1000)]) with gdaltest.config_options({'GDAL_NUM_THREADS': 'ALL_CPUS'}): f = gdal.VSIFOpenL('/vsizip/' + zip_name + '/test2', 'wb') for i in range(niters): gdal.VSIFWriteL(s, 1, len(s), f) gdal.VSIFCloseL(f) size = gdal.VSIStatL(zip_name).size assert size > 0xFFFFFFFF size = gdal.VSIStatL('/vsizip/' + zip_name + '/test2').size assert size == len(s) * niters f = gdal.VSIFOpenL('/vsizip/' + zip_name + '/test2', 'rb') data = gdal.VSIFReadL(1, len(s), f).decode('ascii') gdal.VSIFCloseL(f) assert data == s gdal.Unlink(zip_name)
def test_vsizip_create_zip64(): if not gdaltest.run_slow_tests(): pytest.skip() niters = 1000 s = 'hello' * 1000 * 1000 zip_name = '/vsimem/vsizip_create_zip64.zip' with gdaltest.config_options({'GDAL_NUM_THREADS': 'ALL_CPUS'}): fmain = gdal.VSIFOpenL('/vsizip/' + zip_name, 'wb') f = gdal.VSIFOpenL('/vsizip/' + zip_name + '/test', 'wb') for i in range(niters): gdal.VSIFWriteL(s, 1, len(s), f) gdal.VSIFCloseL(f) gdal.VSIFCloseL(fmain) size = gdal.VSIStatL(zip_name).size assert size <= 0xFFFFFFFF size = gdal.VSIStatL('/vsizip/' + zip_name + '/test').size assert size == len(s) * niters f = gdal.VSIFOpenL('/vsizip/' + zip_name + '/test', 'rb') data = gdal.VSIFReadL(1, len(s), f).decode('ascii') gdal.VSIFCloseL(f) assert data == s gdal.Unlink(zip_name)
def test_gdal_ls_py_8(): if not gdaltest.run_slow_tests(): return 'skip' drv = gdal.GetDriverByName('HTTP') if drv is None: return 'skip' if int(gdal.VersionInfo('VERSION_NUM')) < 1900: gdaltest.post_reason('would stall for a long time') return 'skip' f = gdal.VSIFOpenL('/vsicurl/https://raw.githubusercontent.com/OSGeo/gdal/master/autotest/ogr/data/poly.zip', 'rb') if f is None: return 'skip' d = gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) if not d: return 'skip' ret, ret_str = run_gdal_ls(['', '-l', '-R', '-Rzip', 'ftp://download.osgeo.org/gdal/data/aig']) if ret != 'success': return ret if ret_str.find('-r--r--r-- 1 unknown unknown 24576 2007-03-29 00:00 /vsicurl/ftp://download.osgeo.org/gdal/data/aig/nzdem/info/arc0002r.001') == -1: print(ret_str) return 'fail' if ret_str.find('-r--r--r-- 1 unknown unknown 24576 2007-03-29 12:20 /vsizip//vsicurl/ftp://download.osgeo.org/gdal/data/aig/nzdem.zip/nzdem/info/arc0002r.001') == -1: print(ret_str) return 'fail' return 'success'
def test_gdal_ls_py_8(): if not gdaltest.run_slow_tests(): pytest.skip() drv = gdal.GetDriverByName('HTTP') if drv is None: pytest.skip() if int(gdal.VersionInfo('VERSION_NUM')) < 1900: pytest.skip('would stall for a long time') f = gdal.VSIFOpenL( '/vsicurl/https://raw.githubusercontent.com/OSGeo/gdal/release/3.1/autotest/ogr/data/poly.zip', 'rb') if f is None: pytest.skip() d = gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) if not d: pytest.skip() ret_str = run_gdal_ls( ['', '-l', '-R', '-Rzip', 'ftp://download.osgeo.org/gdal/data/aig']) assert ret_str.find( '-r--r--r-- 1 unknown unknown 24576 2007-03-29 00:00 /vsicurl/ftp://download.osgeo.org/gdal/data/aig/nzdem/info/arc0002r.001' ) != -1 assert ret_str.find( '-r--r--r-- 1 unknown unknown 24576 2007-03-29 12:20 /vsizip//vsicurl/ftp://download.osgeo.org/gdal/data/aig/nzdem.zip/nzdem/info/arc0002r.001' ) != -1
def test_vsicurl_4(): if not gdaltest.run_slow_tests(): pytest.skip() if not gdaltest.built_against_curl(): pytest.skip() ds = ogr.Open('/vsizip/vsicurl/http://lelserver.env.duke.edu:8080/LandscapeTools/export/49/Downloads/1_Habitats.zip') assert ds is None
def vsicurl_3(): if not gdaltest.run_slow_tests(): pytest.skip() if not gdaltest.built_against_curl(): pytest.skip() ds = ogr.Open('/vsizip/vsicurl/http://www.iucnredlist.org/spatial-data/MAMMALS_TERRESTRIAL.zip') assert ds is None
def vsicurl_2(): if not gdaltest.run_slow_tests(): pytest.skip() if not gdaltest.built_against_curl(): pytest.skip() ds = gdal.Open('/vsizip//vsicurl/http://eros.usgs.gov/archive/nslrsda/GeoTowns/HongKong/srtm/n22e113.zip/n22e113.bil') assert ds is not None
def test_vsicurl_1(): if not gdaltest.run_slow_tests(): pytest.skip() if not gdaltest.built_against_curl(): pytest.skip() ds = ogr.Open('/vsizip/vsicurl/http://publicfiles.dep.state.fl.us/dear/BWR_GIS/2007NWFLULC/NWFWMD2007LULC.zip') assert ds is not None
def test_vsicurl_10(): if not gdaltest.run_slow_tests(): pytest.skip() if not gdaltest.built_against_curl(): pytest.skip() ds = gdal.Open('/vsicurl/http://download.osgeo.org/gdal/data/gtiff/xx%E4%B8%AD%E6%96%87.%E4%B8%AD%E6%96%87') assert ds is not None
def test_vsicurl_5(): if not gdaltest.run_slow_tests(): pytest.skip() if not gdaltest.built_against_curl(): pytest.skip() ds = gdal.Open('/vsicurl/http://dds.cr.usgs.gov/srtm/SRTM_image_sample/picture%20examples/N34W119_DEM.tif') assert ds is not None
def test_vsicurl_7(): if not gdaltest.run_slow_tests(): pytest.skip() if not gdaltest.built_against_curl(): pytest.skip() fl = gdal.ReadDir('/vsicurl/http://ortho.linz.govt.nz/tifs/2005_06') assert fl
def vsicurl_6_disabled(): if not gdaltest.run_slow_tests(): pytest.skip() if not gdaltest.built_against_curl(): pytest.skip() fl = gdal.ReadDir('/vsicurl/ftp://ftp2.cits.rncan.gc.ca/pub/cantopo/250k_tif') assert fl
def test_vsicurl_9(): if not gdaltest.run_slow_tests(): pytest.skip() if not gdaltest.built_against_curl(): pytest.skip() ds = gdal.Open('/vsicurl/http://download.osgeo.org/gdal/data/gtiff/' 'xx\u4E2D\u6587.\u4E2D\u6587') assert ds is not None
def vsicurl_8(): if not gdaltest.run_slow_tests(): pytest.skip() if not gdaltest.built_against_curl(): pytest.skip() ds1 = gdal.Open('/vsigzip//vsicurl/http://dds.cr.usgs.gov/pub/data/DEM/250/notavail/C/chipicoten-w.gz') gdal.Open('/vsizip//vsicurl/http://edcftp.cr.usgs.gov/pub/data/landcover/files/2009/biso/gokn09b_dnbr.zip/nps-serotnbsp-9001-20090321_rd.tif') cs = ds1.GetRasterBand(1).Checksum() assert cs == 61342
def vsicurl_7(): if not gdaltest.run_slow_tests(): return 'skip' if not gdaltest.built_against_curl(): return 'skip' fl = gdal.ReadDir('/vsicurl/http://ortho.linz.govt.nz/tifs/2005_06') if len(fl) == 0: return 'fail' return 'success'
def vsicurl_4(): if not gdaltest.run_slow_tests(): return 'skip' if not gdaltest.built_against_curl(): return 'skip' ds = ogr.Open('/vsizip/vsicurl/http://lelserver.env.duke.edu:8080/LandscapeTools/export/49/Downloads/1_Habitats.zip') if ds is not None: return 'fail' return 'success'
def vsicurl_6(): if not gdaltest.run_slow_tests(): return 'skip' if not gdaltest.built_against_curl(): return 'skip' fl = gdal.ReadDir('/vsicurl/ftp://ftp2.cits.rncan.gc.ca/pub/cantopo/250k_tif') if len(fl) == 0: return 'fail' return 'success'
def vsicurl_2(): if not gdaltest.run_slow_tests(): return 'skip' if not gdaltest.built_against_curl(): return 'skip' ds = gdal.Open('/vsizip//vsicurl/http://eros.usgs.gov/archive/nslrsda/GeoTowns/HongKong/srtm/n22e113.zip/n22e113.bil') if ds is None: return 'fail' return 'success'
def vsicurl_10(): if not gdaltest.run_slow_tests(): return 'skip' if not gdaltest.built_against_curl(): return 'skip' ds = gdal.Open('/vsicurl/http://download.osgeo.org/gdal/data/gtiff/xx%E4%B8%AD%E6%96%87.%E4%B8%AD%E6%96%87') if ds is None: return 'fail' return 'success'
def vsicurl_1(): if not gdaltest.run_slow_tests(): return 'skip' if not gdaltest.built_against_curl(): return 'skip' ds = ogr.Open('/vsizip/vsicurl/http://publicfiles.dep.state.fl.us/dear/BWR_GIS/2007NWFLULC/NWFWMD2007LULC.zip') if ds is None: return 'fail' return 'success'
def vsicurl_6_disabled(): if not gdaltest.run_slow_tests(): return 'skip' if not gdaltest.built_against_curl(): return 'skip' fl = gdal.ReadDir('/vsicurl/ftp://ftp2.cits.rncan.gc.ca/pub/cantopo/250k_tif') if not fl: return 'fail' return 'success'
def vsicurl_7(): if not gdaltest.run_slow_tests(): return 'skip' if not gdaltest.built_against_curl(): return 'skip' fl = gdal.ReadDir('/vsicurl/http://ortho.linz.govt.nz/tifs/2005_06') if not fl: return 'fail' return 'success'
def vsicurl_5(): if not gdaltest.run_slow_tests(): return 'skip' if not gdaltest.built_against_curl(): return 'skip' ds = gdal.Open('/vsicurl/http://dds.cr.usgs.gov/srtm/SRTM_image_sample/picture%20examples/N34W119_DEM.tif') if ds is None: return 'fail' return 'success'
def vsicurl_3(): if not gdaltest.run_slow_tests(): return 'skip' if not gdaltest.built_against_curl(): return 'skip' ds = ogr.Open('/vsizip/vsicurl/http://www.iucnredlist.org/spatial-data/MAMMALS_TERRESTRIAL.zip') if ds is not None: return 'fail' return 'success'
def test_vsicurl_9(): if not gdaltest.run_slow_tests(): pytest.skip() if not gdaltest.built_against_curl(): pytest.skip() if version_info >= (3, 0, 0): filename = 'xx\u4E2D\u6587.\u4E2D\u6587' else: exec("filename = u'xx\u4E2D\u6587.\u4E2D\u6587'") filename = filename.encode('utf-8') ds = gdal.Open('/vsicurl/http://download.osgeo.org/gdal/data/gtiff/' + filename) assert ds is not None
def netcdf_34(): filename = 'utm-big-chunks.nc' # this timeout is more than enough - on my system takes <1s with fix, about 25 seconds without timeout = 5 if gdaltest.netcdf_drv is None: return 'skip' if not gdaltest.netcdf_drv_has_nc4: return 'skip' if not gdaltest.run_slow_tests(): return 'skip' try: from multiprocessing import Process except: print('from multiprocessing import Process failed') return 'skip' if not gdaltest.download_file( 'http://download.osgeo.org/gdal/data/netcdf/' + filename, filename): return 'skip' sys.stdout.write('.') sys.stdout.flush() tst = gdaltest.GDALTest('NetCDF', '../tmp/cache/' + filename, 1, 31621) #tst.testOpen() gdal.PushErrorHandler('CPLQuietErrorHandler') proc = Process(target=tst.testOpen) proc.start() proc.join(timeout) gdal.PopErrorHandler() # if proc is alive after timeout we must terminate it, and return fail # valgrind detects memory leaks when this occurs (although it should never happen) if proc.is_alive(): proc.terminate() print( 'testOpen() for file %s has reached timeout limit of %d seconds' % (filename, timeout)) return 'fail' return 'success'
def test_vsicurl_11(): if not gdaltest.run_slow_tests(): pytest.skip() if not gdaltest.built_against_curl(): pytest.skip() f = gdal.VSIFOpenL('/vsicurl/http://download.osgeo.org/gdal/data/bmp/Bug2236.bmp', 'rb') if f is None: pytest.skip() gdal.VSIFSeekL(f, 1000000, 0) gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) filelist = gdal.ReadDir('/vsicurl/http://download.osgeo.org/gdal/data/gtiff') assert filelist is not None and filelist
def vsicurl_10(): if not gdaltest.run_slow_tests(): return 'skip' try: drv = gdal.GetDriverByName( 'HTTP' ) except: drv = None if drv is None: return 'skip' ds = gdal.Open('/vsicurl/http://download.osgeo.org/gdal/data/gtiff/xx%E4%B8%AD%E6%96%87.%E4%B8%AD%E6%96%87') if ds is None: return 'fail' return 'success'
def vsicurl_7(): if not gdaltest.run_slow_tests(): return 'skip' try: drv = gdal.GetDriverByName('HTTP') except: drv = None if drv is None: return 'skip' fl = gdal.ReadDir('/vsicurl/http://ortho.linz.govt.nz/tifs/2005_06') if len(fl) == 0: return 'fail' return 'success'
def vsicurl_2(): if not gdaltest.run_slow_tests(): return 'skip' try: drv = gdal.GetDriverByName( 'HTTP' ) except: drv = None if drv is None: return 'skip' ds = gdal.Open('/vsizip//vsicurl/http://eros.usgs.gov/archive/nslrsda/GeoTowns/HongKong/srtm/n22e113.zip/n22e113.bil') if ds is None: return 'fail' return 'success'
def vsicurl_3(): if not gdaltest.run_slow_tests(): return 'skip' try: drv = gdal.GetDriverByName( 'HTTP' ) except: drv = None if drv is None: return 'skip' ds = ogr.Open('/vsizip/vsicurl/http://www.iucnredlist.org/spatial-data/MAMMALS_TERRESTRIAL.zip') if ds is not None: return 'fail' return 'success'
def vsicurl_1(): if not gdaltest.run_slow_tests(): return 'skip' try: drv = gdal.GetDriverByName( 'HTTP' ) except: drv = None if drv is None: return 'skip' ds = ogr.Open('/vsizip/vsicurl/http://publicfiles.dep.state.fl.us/dear/BWR_GIS/2007NWFLULC/NWFWMD2007LULC.zip') if ds is None: return 'fail' return 'success'
def vsicurl_7(): if not gdaltest.run_slow_tests(): return 'skip' try: drv = gdal.GetDriverByName( 'HTTP' ) except: drv = None if drv is None: return 'skip' fl = gdal.ReadDir('/vsicurl/http://ortho.linz.govt.nz/tifs/2005_06') if len(fl) == 0: return 'fail' return 'success'
def vsicurl_6(): if not gdaltest.run_slow_tests(): return 'skip' try: drv = gdal.GetDriverByName( 'HTTP' ) except: drv = None if drv is None: return 'skip' fl = gdal.ReadDir('/vsicurl/ftp://ftp2.cits.rncan.gc.ca/pub/cantopo/250k_tif') if len(fl) == 0: return 'fail' return 'success'
def vsicurl_5(): if not gdaltest.run_slow_tests(): return 'skip' try: drv = gdal.GetDriverByName( 'HTTP' ) except: drv = None if drv is None: return 'skip' ds = gdal.Open('/vsicurl/http://dds.cr.usgs.gov/srtm/SRTM_image_sample/picture%20examples/N34W119_DEM.tif') if ds is None: return 'fail' return 'success'