def test_vsiaz_no_sign_request(): if not gdaltest.built_against_curl(): pytest.skip() with gdaltest.config_options({ 'AZURE_STORAGE_ACCOUNT': 'naipblobs', 'AZURE_NO_SIGN_REQUEST': 'YES' }): actual_url = gdal.GetActualURL( '/vsiaz/naip/v002/al/2015/al_100cm_2015/30086/m_3008601_ne_16_1_20150804.tif' ) assert actual_url == 'https://naipblobs.blob.core.windows.net/naip/v002/al/2015/al_100cm_2015/30086/m_3008601_ne_16_1_20150804.tif' assert actual_url == gdal.GetSignedURL( '/vsiaz/naip/v002/al/2015/al_100cm_2015/30086/m_3008601_ne_16_1_20150804.tif' ) f = open_for_read( '/vsiaz/naip/v002/al/2015/al_100cm_2015/30086/m_3008601_ne_16_1_20150804.tif' ) if f is None: if gdaltest.gdalurlopen( 'https://naipblobs.blob.core.windows.net/naip/v002/al/2015/al_100cm_2015/30086/m_3008601_ne_16_1_20150804.tif' ) is None: pytest.skip('cannot open URL') pytest.fail() gdal.VSIFCloseL(f) assert 'm_3008601_ne_16_1_20150804.tif' in gdal.ReadDir( '/vsiaz/naip/v002/al/2015/al_100cm_2015/30086/')
def test_visoss_1(): if not gdaltest.built_against_curl(): pytest.skip() # Missing OSS_SECRET_ACCESS_KEY gdal.ErrorReset() with gdaltest.error_handler(): f = open_for_read('/vsioss/foo/bar') assert f is None and gdal.VSIGetLastErrorMsg().find('OSS_SECRET_ACCESS_KEY') >= 0 gdal.ErrorReset() with gdaltest.error_handler(): f = open_for_read('/vsioss_streaming/foo/bar') assert f is None and gdal.VSIGetLastErrorMsg().find('OSS_SECRET_ACCESS_KEY') >= 0 gdal.SetConfigOption('OSS_SECRET_ACCESS_KEY', 'OSS_SECRET_ACCESS_KEY') # Missing OSS_ACCESS_KEY_ID gdal.ErrorReset() with gdaltest.error_handler(): f = open_for_read('/vsioss/foo/bar') assert f is None and gdal.VSIGetLastErrorMsg().find('OSS_ACCESS_KEY_ID') >= 0 gdal.SetConfigOption('OSS_ACCESS_KEY_ID', 'OSS_ACCESS_KEY_ID')
def test_vsiaz_sas(): if not gdaltest.built_against_curl(): pytest.skip() # See https://azure.microsoft.com/en-us/services/open-datasets/catalog/naip/ for the value of AZURE_SAS with gdaltest.config_options({ 'AZURE_STORAGE_ACCOUNT': 'naipblobs', 'AZURE_SAS': 'st=2019-07-18T03%3A53%3A22Z&se=2035-07-19T03%3A53%3A00Z&sp=rl&sv=2018-03-28&sr=c&sig=2RIXmLbLbiagYnUd49rgx2kOXKyILrJOgafmkODhRAQ%3D' }): actual_url = gdal.GetActualURL( '/vsiaz/naip/v002/al/2015/al_100cm_2015/30086/m_3008601_ne_16_1_20150804.tif' ) assert actual_url == 'https://naipblobs.blob.core.windows.net/naip/v002/al/2015/al_100cm_2015/30086/m_3008601_ne_16_1_20150804.tif' assert gdal.GetSignedURL( '/vsiaz/naip/v002/al/2015/al_100cm_2015/30086/m_3008601_ne_16_1_20150804.tif' ) == 'https://naipblobs.blob.core.windows.net/naip/v002/al/2015/al_100cm_2015/30086/m_3008601_ne_16_1_20150804.tif?st=2019-07-18T03%3A53%3A22Z&se=2035-07-19T03%3A53%3A00Z&sp=rl&sv=2018-03-28&sr=c&sig=2RIXmLbLbiagYnUd49rgx2kOXKyILrJOgafmkODhRAQ%3D' f = open_for_read( '/vsiaz/naip/v002/al/2015/al_100cm_2015/30086/m_3008601_ne_16_1_20150804.tif' ) if f is None: if gdaltest.gdalurlopen( 'https://naipblobs.blob.core.windows.net/naip/v002/al/2015/al_100cm_2015/30086/m_3008601_ne_16_1_20150804.tif' ) is None: pytest.skip('cannot open URL') pytest.fail() gdal.VSIFCloseL(f) assert 'm_3008601_ne_16_1_20150804.tif' in gdal.ReadDir( '/vsiaz/naip/v002/al/2015/al_100cm_2015/30086/')
def test_visoss_1(): if not gdaltest.built_against_curl(): pytest.skip() # Missing OSS_SECRET_ACCESS_KEY gdal.ErrorReset() with gdaltest.error_handler(): f = open_for_read('/vsioss/foo/bar') assert f is None and gdal.VSIGetLastErrorMsg().find( 'OSS_SECRET_ACCESS_KEY') >= 0 gdal.ErrorReset() with gdaltest.error_handler(): f = open_for_read('/vsioss_streaming/foo/bar') assert f is None and gdal.VSIGetLastErrorMsg().find( 'OSS_SECRET_ACCESS_KEY') >= 0 gdal.SetConfigOption('OSS_SECRET_ACCESS_KEY', 'OSS_SECRET_ACCESS_KEY') # Missing OSS_ACCESS_KEY_ID gdal.ErrorReset() with gdaltest.error_handler(): f = open_for_read('/vsioss/foo/bar') assert f is None and gdal.VSIGetLastErrorMsg().find( 'OSS_ACCESS_KEY_ID') >= 0 gdal.SetConfigOption('OSS_ACCESS_KEY_ID', 'OSS_ACCESS_KEY_ID')
def vsigs_extra_1(): if not gdaltest.built_against_curl(): return 'skip' if gdal.GetConfigOption('GS_SECRET_ACCESS_KEY') is None: print('Missing GS_SECRET_ACCESS_KEY for running gdaltest_list_extra') return 'skip' elif gdal.GetConfigOption('GS_ACCESS_KEY_ID') is None: print('Missing GS_ACCESS_KEY_ID for running gdaltest_list_extra') return 'skip' elif gdal.GetConfigOption('GS_RESOURCE') is None: print('Missing GS_RESOURCE for running gdaltest_list_extra') return 'skip' f = open_for_read('/vsigs/' + gdal.GetConfigOption('GS_RESOURCE')) if f is None: gdaltest.post_reason('fail') return 'fail' ret = gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) if len(ret) != 1: gdaltest.post_reason('fail') print(ret) return 'fail' # Same with /vsigs_streaming/ f = open_for_read('/vsigs_streaming/' + gdal.GetConfigOption('GS_RESOURCE')) if f is None: gdaltest.post_reason('fail') return 'fail' ret = gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) if len(ret) != 1: gdaltest.post_reason('fail') print(ret) return 'fail' # Invalid bucket : "The specified bucket does not exist" gdal.ErrorReset() f = open_for_read('/vsigs/not_existing_bucket/foo') with gdaltest.error_handler(): gdal.VSIFReadL(1, 1, f) gdal.VSIFCloseL(f) if gdal.VSIGetLastErrorMsg() == '': gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' # Invalid resource gdal.ErrorReset() f = open_for_read('/vsigs_streaming/' + gdal.GetConfigOption('GS_RESOURCE') + '/invalid_resource.baz') if f is not None: gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' return 'success'
def test_eedai_gce_credentials(): if gdaltest.eedai_drv is None: pytest.skip() gdaltest.webserver_process = None gdaltest.webserver_port = 0 if not gdaltest.built_against_curl(): pytest.skip() (gdaltest.webserver_process, gdaltest.webserver_port) = webserver.launch(handler=webserver.DispatcherHttpHandler) if gdaltest.webserver_port == 0: pytest.skip() gdal.SetConfigOption('CPL_GCE_CREDENTIALS_URL', 'http://localhost:%d/computeMetadata/v1/instance/service-accounts/default/token' % gdaltest.webserver_port) # Disable hypervisor related check to test if we are really on EC2 gdal.SetConfigOption('CPL_GCE_CHECK_LOCAL_FILES', 'NO') gdal.VSICurlClearCache() def method(request): if 'Authorization' not in request.headers: sys.stderr.write('Bad headers: %s\n' % str(request.headers)) request.send_response(403) return expected_authorization = 'Bearer ACCESS_TOKEN' if request.headers['Authorization'] != expected_authorization: sys.stderr.write("Bad Authorization: '%s'\n" % str(request.headers['Authorization'])) request.send_response(403) return request.send_response(200) request.send_header('Content-type', 'text/plain') request.send_header('Content-Length', 3) request.end_headers() request.wfile.write("""foo""".encode('ascii')) handler = webserver.SequentialHandler() handler.add('GET', '/computeMetadata/v1/instance/service-accounts/default/token', 200, {}, """{ "access_token" : "ACCESS_TOKEN", "token_type" : "Bearer", "expires_in" : 3600, }""") with webserver.install_http_handler(handler): gdal.SetConfigOption('EEDA_URL', '/vsimem/ee/') ds = gdal.Open('EEDAI:image') gdal.SetConfigOption('EEDA_URL', None) gdal.SetConfigOption('CPL_GCE_CREDENTIALS_URL', None) gdal.SetConfigOption('CPL_GCE_CHECK_LOCAL_FILES', None) webserver.server_stop(gdaltest.webserver_process, gdaltest.webserver_port) 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 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 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_vsiaz_real_server_errors(): if not gdaltest.built_against_curl(): pytest.skip() # Missing AZURE_STORAGE_ACCOUNT gdal.ErrorReset() with gdaltest.error_handler(): f = open_for_read('/vsiaz/foo/bar') assert f is None and gdal.VSIGetLastErrorMsg().find( 'AZURE_STORAGE_ACCOUNT') >= 0 gdal.ErrorReset() with gdaltest.error_handler(): f = open_for_read('/vsiaz_streaming/foo/bar') assert f is None and gdal.VSIGetLastErrorMsg().find( 'AZURE_STORAGE_ACCOUNT') >= 0 # Invalid AZURE_STORAGE_CONNECTION_STRING with gdaltest.config_option('AZURE_STORAGE_CONNECTION_STRING', 'invalid'): gdal.ErrorReset() with gdaltest.error_handler(): f = open_for_read('/vsiaz/foo/bar') assert f is None # Missing AZURE_STORAGE_ACCESS_KEY gdal.ErrorReset() with gdaltest.config_options({ 'AZURE_STORAGE_ACCOUNT': 'AZURE_STORAGE_ACCOUNT', 'CPL_AZURE_VM_API_ROOT_URL': 'disabled' }): with gdaltest.error_handler(): f = open_for_read('/vsiaz/foo/bar') assert f is None and gdal.VSIGetLastErrorMsg().find( 'AZURE_STORAGE_ACCESS_KEY') >= 0 # AZURE_STORAGE_ACCOUNT and AZURE_STORAGE_ACCESS_KEY but invalid gdal.ErrorReset() with gdaltest.config_options({ 'AZURE_STORAGE_ACCOUNT': 'AZURE_STORAGE_ACCOUNT', 'AZURE_STORAGE_ACCESS_KEY': 'AZURE_STORAGE_ACCESS_KEY' }): with gdaltest.error_handler(): f = open_for_read('/vsiaz/foo/bar.baz') if f is not None: if f is not None: gdal.VSIFCloseL(f) if gdal.GetConfigOption('APPVEYOR') is not None: return pytest.fail(gdal.VSIGetLastErrorMsg()) gdal.ErrorReset() with gdaltest.error_handler(): f = open_for_read('/vsiaz_streaming/foo/bar.baz') assert f is None, gdal.VSIGetLastErrorMsg()
def vsiswift_real_server_errors(): if not gdaltest.built_against_curl(): return 'skip' # Nothing set gdal.ErrorReset() with gdaltest.error_handler(): f = open_for_read('/vsiswift/foo/bar') if f is not None or gdal.VSIGetLastErrorMsg().find( 'SWIFT_STORAGE_URL') < 0: gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' gdal.ErrorReset() with gdaltest.error_handler(): f = open_for_read('/vsiswift_streaming/foo/bar') if f is not None or gdal.VSIGetLastErrorMsg().find( 'SWIFT_STORAGE_URL') < 0: gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' gdal.SetConfigOption('SWIFT_STORAGE_URL', 'http://0.0.0.0') # Missing SWIFT_AUTH_TOKEN gdal.ErrorReset() with gdaltest.error_handler(): f = open_for_read('/vsiswift/foo/bar') if f is not None or gdal.VSIGetLastErrorMsg().find('SWIFT_AUTH_TOKEN') < 0: gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' gdal.SetConfigOption('SWIFT_AUTH_TOKEN', 'SWIFT_AUTH_TOKEN') gdal.ErrorReset() with gdaltest.error_handler(): f = open_for_read('/vsiswift/foo/bar.baz') if f is not None: if f is not None: gdal.VSIFCloseL(f) gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' gdal.ErrorReset() with gdaltest.error_handler(): f = open_for_read('/vsiswift_streaming/foo/bar.baz') if f is not None: gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' return 'success'
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 vsiswift_real_server_errors(): if not gdaltest.built_against_curl(): return 'skip' # Nothing set gdal.ErrorReset() with gdaltest.error_handler(): f = open_for_read('/vsiswift/foo/bar') if f is not None or gdal.VSIGetLastErrorMsg().find('SWIFT_STORAGE_URL') < 0: gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' gdal.ErrorReset() with gdaltest.error_handler(): f = open_for_read('/vsiswift_streaming/foo/bar') if f is not None or gdal.VSIGetLastErrorMsg().find('SWIFT_STORAGE_URL') < 0: gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' gdal.SetConfigOption('SWIFT_STORAGE_URL', 'http://0.0.0.0') # Missing SWIFT_AUTH_TOKEN gdal.ErrorReset() with gdaltest.error_handler(): f = open_for_read('/vsiswift/foo/bar') if f is not None or gdal.VSIGetLastErrorMsg().find('SWIFT_AUTH_TOKEN') < 0: gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' gdal.SetConfigOption('SWIFT_AUTH_TOKEN', 'SWIFT_AUTH_TOKEN') gdal.ErrorReset() with gdaltest.error_handler(): f = open_for_read('/vsiswift/foo/bar.baz') if f is not None: if f is not None: gdal.VSIFCloseL(f) gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' gdal.ErrorReset() with gdaltest.error_handler(): f = open_for_read('/vsiswift_streaming/foo/bar.baz') if f is not None: gdaltest.post_reason('fail') print(gdal.VSIGetLastErrorMsg()) return 'fail' return 'success'
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 test_vsiswift_start_webserver(): gdaltest.webserver_process = None gdaltest.webserver_port = 0 if not gdaltest.built_against_curl(): pytest.skip() (gdaltest.webserver_process, gdaltest.webserver_port) = webserver.launch(handler=webserver.DispatcherHttpHandler) if gdaltest.webserver_port == 0: pytest.skip()
def test_vsicurl_start_webserver(): gdaltest.webserver_process = None gdaltest.webserver_port = 0 if not gdaltest.built_against_curl(): pytest.skip() (gdaltest.webserver_process, gdaltest.webserver_port) = webserver.launch(handler=webserver.DispatcherHttpHandler) if gdaltest.webserver_port == 0: pytest.skip()
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_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_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 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_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_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_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_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_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_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 vsiswift_start_webserver(): gdaltest.webserver_process = None gdaltest.webserver_port = 0 if not gdaltest.built_against_curl(): return 'skip' (gdaltest.webserver_process, gdaltest.webserver_port) = webserver.launch(handler = webserver.DispatcherHttpHandler) if gdaltest.webserver_port == 0: return 'skip' return 'success'
def vsiswift_start_webserver(): gdaltest.webserver_process = None gdaltest.webserver_port = 0 if not gdaltest.built_against_curl(): return 'skip' (gdaltest.webserver_process, gdaltest.webserver_port) = webserver.launch(handler=webserver.DispatcherHttpHandler) if gdaltest.webserver_port == 0: return 'skip' return 'success'
def test_vsigs_start_webserver(): gdaltest.webserver_process = None gdaltest.webserver_port = 0 if not gdaltest.built_against_curl(): pytest.skip() (gdaltest.webserver_process, gdaltest.webserver_port) = webserver.launch(handler=webserver.DispatcherHttpHandler) if gdaltest.webserver_port == 0: pytest.skip() gdal.SetConfigOption('CPL_GS_ENDPOINT', 'http://127.0.0.1:%d/' % gdaltest.webserver_port) gdal.SetConfigOption('GS_SECRET_ACCESS_KEY', 'GS_SECRET_ACCESS_KEY') gdal.SetConfigOption('GS_ACCESS_KEY_ID', 'GS_ACCESS_KEY_ID')
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 vsigs_start_webserver(): gdaltest.webserver_process = None gdaltest.webserver_port = 0 if not gdaltest.built_against_curl(): return 'skip' (gdaltest.webserver_process, gdaltest.webserver_port) = webserver.launch(handler = webserver.DispatcherHttpHandler) if gdaltest.webserver_port == 0: return 'skip' gdal.SetConfigOption('CPL_GS_ENDPOINT', 'http://127.0.0.1:%d/' % gdaltest.webserver_port) return 'success'
def test_vsiaz_real_server_errors(): if not gdaltest.built_against_curl(): pytest.skip() # Missing AZURE_STORAGE_ACCOUNT gdal.ErrorReset() with gdaltest.error_handler(): f = open_for_read('/vsiaz/foo/bar') assert f is None and gdal.VSIGetLastErrorMsg().find('AZURE_STORAGE_ACCOUNT') >= 0 gdal.ErrorReset() with gdaltest.error_handler(): f = open_for_read('/vsiaz_streaming/foo/bar') assert f is None and gdal.VSIGetLastErrorMsg().find('AZURE_STORAGE_ACCOUNT') >= 0 # Invalid AZURE_STORAGE_CONNECTION_STRING gdal.SetConfigOption('AZURE_STORAGE_CONNECTION_STRING', 'invalid') gdal.ErrorReset() with gdaltest.error_handler(): f = open_for_read('/vsiaz/foo/bar') assert f is None gdal.SetConfigOption('AZURE_STORAGE_CONNECTION_STRING', '') gdal.SetConfigOption('AZURE_STORAGE_ACCOUNT', 'AZURE_STORAGE_ACCOUNT') # Missing AZURE_STORAGE_ACCESS_KEY gdal.ErrorReset() with gdaltest.error_handler(): f = open_for_read('/vsiaz/foo/bar') assert f is None and gdal.VSIGetLastErrorMsg().find('AZURE_STORAGE_ACCESS_KEY') >= 0 gdal.SetConfigOption('AZURE_STORAGE_ACCESS_KEY', 'AZURE_STORAGE_ACCESS_KEY') gdal.ErrorReset() with gdaltest.error_handler(): f = open_for_read('/vsiaz/foo/bar.baz') if f is not None: if f is not None: gdal.VSIFCloseL(f) if gdal.GetConfigOption('APPVEYOR') is not None: return pytest.fail(gdal.VSIGetLastErrorMsg()) gdal.ErrorReset() with gdaltest.error_handler(): f = open_for_read('/vsiaz_streaming/foo/bar.baz') assert f is None, gdal.VSIGetLastErrorMsg()
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 test_vsiwebhdfs_start_webserver(): gdaltest.webserver_process = None gdaltest.webserver_port = 0 if not gdaltest.built_against_curl(): pytest.skip() (gdaltest.webserver_process, gdaltest.webserver_port) = webserver.launch( handler=webserver.DispatcherHttpHandler) if gdaltest.webserver_port == 0: pytest.skip() gdaltest.webhdfs_base_connection = '/vsiwebhdfs/http://localhost:' + \ str(gdaltest.webserver_port) + '/webhdfs/v1' gdaltest.webhdfs_redirected_url = 'http://non_existing_host:' + \ str(gdaltest.webserver_port) + '/redirected'
def test_vsiaz_start_webserver(): gdaltest.webserver_process = None gdaltest.webserver_port = 0 if not gdaltest.built_against_curl(): pytest.skip() (gdaltest.webserver_process, gdaltest.webserver_port) = webserver.launch(handler=webserver.DispatcherHttpHandler) if gdaltest.webserver_port == 0: pytest.skip() gdal.SetConfigOption('AZURE_STORAGE_CONNECTION_STRING', 'DefaultEndpointsProtocol=http;AccountName=myaccount;AccountKey=MY_ACCOUNT_KEY;EndpointSuffix=127.0.0.1:%d' % gdaltest.webserver_port) gdal.SetConfigOption('AZURE_STORAGE_ACCOUNT', '') gdal.SetConfigOption('AZURE_STORAGE_ACCESS_KEY', '') gdal.SetConfigOption('CPL_AZURE_TIMESTAMP', 'my_timestamp')
def test_visoss_start_webserver(): gdaltest.webserver_process = None gdaltest.webserver_port = 0 if not gdaltest.built_against_curl(): pytest.skip() (gdaltest.webserver_process, gdaltest.webserver_port) = webserver.launch(handler=webserver.DispatcherHttpHandler) if gdaltest.webserver_port == 0: pytest.skip() gdal.SetConfigOption('OSS_SECRET_ACCESS_KEY', 'OSS_SECRET_ACCESS_KEY') gdal.SetConfigOption('OSS_ACCESS_KEY_ID', 'OSS_ACCESS_KEY_ID') gdal.SetConfigOption('CPL_OSS_TIMESTAMP', 'my_timestamp') gdal.SetConfigOption('OSS_HTTPS', 'NO') gdal.SetConfigOption('OSS_VIRTUAL_HOSTING', 'NO') gdal.SetConfigOption('OSS_ENDPOINT', '127.0.0.1:%d' % gdaltest.webserver_port)
def vsicurl_9(): if not gdaltest.run_slow_tests(): return 'skip' if not gdaltest.built_against_curl(): return '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) if ds is None: return 'fail' return 'success'
def vsicurl_11(): if not gdaltest.run_slow_tests(): return 'skip' if not gdaltest.built_against_curl(): 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 not filelist: return 'fail' return 'success'