Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport master] Stronger update po #10390

Merged
merged 2 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions geoportal/c2cgeoportal_geoportal/lib/lingua_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
from c2cgeoportal_commons.models import main # pylint: disable=ungrouped-imports,useless-suppression


class LinguaExtractorException(Exception):
"""Exception raised when an error occurs during the extraction."""


def _get_config(key: str, default: Optional[str] = None) -> Optional[str]:
"""
Return the config value for passed key.
Expand Down Expand Up @@ -767,19 +771,32 @@ def _layer_attributes(self, url: str, layer: str) -> Tuple[List[str], List[str]]
print(f"Get WMS GetCapabilities for URL {wms_getcap_url},\nwith headers: {rendered_headers}")
response = requests.get(wms_getcap_url, headers=headers, **kwargs)

try:
self.wms_capabilities_cache[url] = WebMapService(None, xml=response.content)
except Exception as e:
if response.ok:
try:
self.wms_capabilities_cache[url] = WebMapService(None, xml=response.content)
except Exception as e:
print(
colorize(
"ERROR! an error occurred while trying to parse "
"the GetCapabilities document.",
Color.RED,
)
)
print(colorize(str(e), Color.RED))
print(f"URL: {wms_getcap_url}\nxml:\n{response.text}")
if _get_config_str("IGNORE_I18N_ERRORS", "FALSE") != "TRUE":
raise
else:
print(
colorize(
"ERROR! an error occurred while trying to parse the GetCapabilities document.",
f"ERROR! Unable to GetCapabilities from URL: {wms_getcap_url},\n"
f"with headers: {rendered_headers}",
Color.RED,
)
)
print(colorize(str(e), Color.RED))
print(f"URL: {wms_getcap_url}\nxml:\n{response.text}")
print(f"Response: {response.status_code} {response.reason}\n{response.text}")
if _get_config_str("IGNORE_I18N_ERRORS", "FALSE") != "TRUE":
raise
raise LinguaExtractorException(response.reason)
except Exception as e:
print(colorize(str(e), Color.RED))
rendered_headers = " ".join(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ help: ## Display this help message

.PHONY: update-po-from-url
update-po-from-url: ## Update the po files from the URL provide by PROJECT_PUBLIC_URL
curl $(PROJECT_PUBLIC_URL)locale.pot > geoportal/${PACKAGE}_geoportal/locale/${PACKAGE}_geoportal-client${SUFFIX}.pot
curl --fail $(PROJECT_PUBLIC_URL)locale.pot > geoportal/${PACKAGE}_geoportal/locale/${PACKAGE}_geoportal-client${SUFFIX}.pot
sed -i '/^"POT-Creation-Date: /d' geoportal/${PACKAGE}_geoportal/locale/${PACKAGE}_geoportal-client${SUFFIX}.pot
docker-compose run --rm -T tools update-po-only `id --user` `id --group` $(LANGUAGES)

Expand Down