[QGIS-Developer] Cannot load WMS capabilities from WMS provider in QGIS3 from python

David Marteau dmarteau at 3liz.com
Mon Jan 15 06:05:52 PST 2018


> 
> 
> 
> Hi David, 
> 
> You  need an event loop to use a Q(qg)NetworkAccessManager, it's asynchronous.
> 

Hi Alessandro,

Yes, we know that (see the second code in previous mail  ):  the  QgsNetworkAccessManager works perfeclty in python, this is not the point.

The point is: trying to instanciate  a  wmsprovider will issue a timeout when trying to request the capabilities: the code responsible for that creates its own QEventLoop and manage to do a blocking call (which is expected here). 
Please have a look at https://github.com/qgis/QGIS/blob/master/src/providers/wms/qgswmscapabilities.cpp#L1964 <https://github.com/qgis/QGIS/blob/master/src/providers/wms/qgswmscapabilities.cpp#L1964>.  What we do not understand is why, despite the call of loop.exec() in the c++ code, the request is not processed (my example with the  Q(gs)etworkAccessManager
shows that it should processed)

Actually you cannot instanciate properly a QgsProject with a WMS layer.

To convince yourself, try to instanciate a QgsProject in python (in a standalone python script) from a .qgs project having a single wms layer: it will fail to instanciate the layer.

> 
> 
> -- 
> Alessandro Pasotti
> w3:   www.itopen.it <http://www.itopen.it/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20180115/5e516f7c/attachment.html>


More information about the QGIS-Developer mailing list