[QGIS-Developer] enabling proxy for wms/wmts layer

Lucia Kadlecova job.kadlecova at gmail.com
Mon Mar 14 11:47:05 PDT 2022


Hello,
I would like to ask how to enable proxies when adding WMTS via WMS. On
server where I run standalone QGIS python to access the WMTS I need to
execute below commands to be able connect from server to net.

export http_proxy=http://xx.xx.xx.xx:8080/
export https_proxy=https://xx.xx.xx.xx:8080/

I tried to add to below code via subprocess.run, but no success

projectName = 'wms_load'
project = QgsProject.instance()
urlWithParams =
'crs=EPSG:3857&dpiMode=7&format=image/png&layers=geolandbasemap&styles=normal&tileMatrixSet=google3857&url=https://www.basemap.at/wmts/1.0.0/WMTSCapabilities.xml'

rlayer = QgsRasterLayer(urlWithParams, 'geolandbasemap', 'wms')
if not rlayer.isValid():
  print("Layer failed to load!")
else:
    print('Layer loaded')
project.addMapLayer(rlayer)

project = QgsProject.instance()
project.write()

qgs.exitQgis()


Thank you
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20220314/9d50da4d/attachment.html>


More information about the QGIS-Developer mailing list