[Qgis-user] [QGIS-Developer] Python Implementation of QgsNetworkContentFetcher
Nyall Dawson
nyall.dawson at gmail.com
Tue Nov 26 15:24:53 PST 2019
On Wed, 27 Nov 2019 at 00:35, C Hamilton <adenaculture at gmail.com> wrote:
>
> Thanks everyone. This gives me some good ideas. These are the possible solutions:
>
> 1. Write a python implementation of QgsNetworkContentFetcher or QgsBlockingNetworkRequest. With this I could look at the QGIS version and if it is 3.10 or greater import the core method; otherwise, import the python implementation.
Trust me -- don't do this. When I wrote the c++ version it nearly
killed me, it's insanely complex with many many components at play.
> 2. Use the old Boundless implementation if it still works in QGIS 3.
I'd do this, but only for QGIS < 3.6. For 3.6 and above use
QgsBlockingNetworkRequest, and when 3.4 is EOLed in a couple of months
you can rely on QgsBlockingNetworkRequest everywhere.
> 3. Use QgsFileDownloader and save it as a temporary file before processing.
Also a good idea, but be aware that it's not blocking, which can mean
it can't be used in certain places. Warning: DO NOT USE
QApplication.processEvents() or a QEventLoop to try to emulate
blocking behavior with this class!
Nyall
>
> Calvin
>
> On Tue, Nov 26, 2019 at 2:29 AM Alessandro Pasotti <apasotti at gmail.com> wrote:
>>
>>
>>
>> On Tue, Nov 26, 2019 at 8:22 AM Richard Duivenvoorde <rdmailings at duif.net> wrote:
>>>
>>> On 26/11/2019 00.06, Nyall Dawson wrote:
>>>
>>> > There's not. But there's the ex-boundless "networkaccessmanager"
>>> > implementation that supports authcfg, which you can find at
>>> > https://github.com/north-road/qgis-redistricting-plugin/blob/master/redistrict/linz/networkaccessmanager.py
>>> > (and other projects -- as far as I'm aware there's no real upstream
>>> > for this... Alessandro?).
>>>
>>> I used this Boundless thingie for several plugins now (original source
>>> is now pointing/redirecting to planetlabs [0]).
>>
>>
>> Yes, that's the "upstream" but I don't know if that one is maintained anymore.
>>
>> Btw, there is also a specialized class for sync/async downloads that supports authcfg: https://qgis.org/api/classQgsFileDownloader.html#details
>>
>>
>>>
>>>
>>> I think we already discussed several times that it would be good to
>>> incorporate this into a commons lib for QGIS. But if I'm correct the
>>> actual interface was not exactly what some wanted, and if I recall
>>> correct Nyall tried to pull this into c++ but hit some multithreading
>>> issues.
>>>
>>> But as Nyall says: I think this is a great lib to use in a plugin (also
>>> because it used the QgisNetwork-stuff, so you can receive the signals
>>> from it or log the precise urls, like we do in the QGISnetworklogger
>>> plugin [1]
>>>
>>> Regards,
>>>
>>> Richard Duivenvoorde
>>>
>>> [0]
>>> https://github.com/planetfederal/lib-qgis-commons/blob/master/qgiscommons2/network/networkaccessmanager.py
>>> [1] https://github.com/rduivenvoorde/qgisnetworklogger
>>> _______________________________________________
>>> Qgis-user mailing list
>>> Qgis-user at lists.osgeo.org
>>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>
>>
>>
>> --
>> Alessandro Pasotti
>> w3: www.itopen.it
More information about the Qgis-user
mailing list