Skip to content

Commit 85ec1d3

Browse files
committed
Don't attempt to read project translations if GetTranslatons server plugin is not installed
1 parent f4a0bf0 commit 85ec1d3

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/config_generator/capabilities_reader.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ def __init__(self, generator_config, logger, use_cached_project_metadata, cache_
4747
"project_settings_read_timeout", 60
4848
)
4949

50+
self.have_get_translations = None
51+
5052

5153
def fetch_cached(self, request_url, params, cache_name, description, silent=False):
5254
document = None
@@ -632,6 +634,25 @@ def read_project_translations(self, service_name, viewer_languages):
632634
:param list viewer_languages: viewer languages
633635
634636
"""
637+
if self.have_get_translations == None:
638+
# Send one request to check whether GetTranslations is available
639+
response = requests.get(
640+
urljoin(
641+
self.default_qgis_server_url,
642+
posixpath.join(self.qgis_server_url_tenant_suffix, service_name)
643+
),
644+
params={'SERVICE': 'GetTranslations', 'LANG': 'en-US'},
645+
timeout=self.project_settings_read_timeout
646+
)
647+
if b'Service unknown or unsupported.' in response.content:
648+
self.logger.info("Cannot read project translations, the QGIS Server GetTranslations plugin is not installed")
649+
self.have_get_translations = False
650+
else:
651+
self.have_get_translations = True
652+
653+
if not self.have_get_translations:
654+
return {}
655+
635656
all_translations = {}
636657
for language in viewer_languages:
637658
try:

0 commit comments

Comments
 (0)