On 3/14/22 19:47, Lucia Kadlecova via QGIS-Developer wrote:
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/ <http://xx.xx.xx.xx:8080/>
export https_proxy=https://xx.xx.xx.xx:8080/ <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
 <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()|

Hi Lucia,

For what I know QGIS is not picking up the proxies from the environment. It is 
using
https://qgis.org/pyqgis/3.6/core/QgsNetworkAccessManager.html for all network 
requests, and (like you have to explicitly set a proxy in settings/network in 
QGIS) you probably have to use/set a 'proxyFactory' in your code.

Not 100% sure about this, and I agree that it would be better/nice if Qt/QGIS 
would pick up proxy settings from the environment (and maybe it does, can you 
ask in you script for that?).

Regards,

Richard Duivenvoorde
_______________________________________________
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to