Skip to content

Commit

Permalink
QNetworkAccessManager -> QgsNetworkContentFetcher #1
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolaiLolansen committed Mar 25, 2021
1 parent d73a9a6 commit ffd2084
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions Dataforsyningen/df_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,15 @@
import hashlib
import glob
from qgis.gui import QgsMessageBar
from qgis.core import *
from qgis.core import QgsMessageLog, QgsNetworkContentFetcher
from qgis.PyQt.QtCore import (
QCoreApplication,
QFileInfo,
QFile,
QUrl,
QSettings,
QTranslator,
qVersion,
QIODevice,
)
from qgis.PyQt.QtNetwork import QNetworkAccessManager, QNetworkRequest
from qgis.PyQt.QtWidgets import QAction, QMenu, QPushButton
from qgis.PyQt.QtGui import QIcon
from qgis.PyQt import QtCore, QtXml
Expand Down Expand Up @@ -50,10 +47,10 @@ def __init__(self, settings):
self.categories = None

# Network
self._services_network_manager = QNetworkAccessManager()
self._qlr_network_manager = QNetworkAccessManager()
self._services_network_manager.finished.connect(self._handle_services_response)
self._qlr_network_manager.finished.connect(self._handle_qlr_response)
self._services_network_fetcher = QgsNetworkContentFetcher()
self._qlr_network_fetcher = QgsNetworkContentFetcher()
self._services_network_fetcher.finished.connect(self._handle_services_response)
self._qlr_network_fetcher.finished.connect(self._handle_qlr_response)

def begin_load(self):
self.cached_df_qlr_filename = (
Expand All @@ -78,9 +75,11 @@ def begin_load(self):

def _request_services(self):
url_to_get = self.insert_token(DF_SERVICES_URL)
self._services_network_manager.get(QNetworkRequest(QUrl(url_to_get)))
self._services_network_fetcher.fetchContent(QUrl(url_to_get))

def _handle_services_response(self):
network_reply = self._services_network_fetcher.reply()

def _handle_services_response(self, network_reply):
if network_reply.error():
self.background_category = None
self.categories = []
Expand Down Expand Up @@ -135,9 +134,11 @@ def _get_qlr_file(self):

def _request_df_qlr_file(self):
url_to_get = self.settings.value("df_qlr_url")
self._qlr_network_manager.get(QNetworkRequest(QUrl(url_to_get)))

def _handle_qlr_response(self, network_reply):
self._qlr_network_fetcher.fetchContent(QUrl(url_to_get))

def _handle_qlr_response(self):
network_reply = self._qlr_network_fetcher.reply()

if network_reply.error():
log_message(
"No contact to the configuration at "
Expand Down

0 comments on commit ffd2084

Please sign in to comment.