Skip to content

Commit b9d7958

Browse files
authored
Merge pull request #84 from gacarrillor/fix_51
[wmts] Check that we've got a file path before attempting to parse it
2 parents 0e64bc7 + 9703a2d commit b9d7958

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

swiss_locator/core/filters/swiss_locator_filter_wmts.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
from qgis.gui import QgisInterface
2424
from qgis.core import (
25+
Qgis,
2526
QgsApplication,
2627
QgsBlockingNetworkRequest,
2728
QgsFetchedContent,
@@ -55,7 +56,7 @@ def __init__(self, iface: QgisInterface = None, crs: str = None, capabilities=No
5556

5657
self.info(self.content.status())
5758

58-
if self.content.status() == QgsFetchedContent.ContentStatus.Finished:
59+
if self.content.status() == QgsFetchedContent.ContentStatus.Finished and self.content.filePath():
5960
file_path = self.content.filePath()
6061
self.info(
6162
f"Swisstopo capabilities already downloaded. Reading from {file_path}"
@@ -91,11 +92,16 @@ def prefix(self):
9192
return "chw"
9293

9394
def handle_capabilities_response(self):
94-
if self.content.status() == QgsFetchedContent.ContentStatus.Finished:
95+
if self.content.status() == QgsFetchedContent.ContentStatus.Finished and self.content.filePath():
9596
self.info(
9697
f"Swisstopo capabilities has been downloaded. Reading from {self.content.filePath()}"
9798
)
9899
self.capabilities = ET.parse(self.content.filePath()).getroot()
100+
else:
101+
self.info(
102+
"The Swiss Locator filter for WMTS layers could not fetch capabilities",
103+
Qgis.Critical
104+
)
99105

100106
def perform_fetch_results(self, search: str, feedback: QgsFeedback):
101107
namespaces = {

0 commit comments

Comments
 (0)