From 5190d6e5540cb1344d48f603528ca0eb73ada436 Mon Sep 17 00:00:00 2001 From: Owen McGonagle <omcgonag@redhat.com> Date: Fri, 17 Jan 2025 11:59:29 -0500 Subject: [PATCH] Non-existent timezone fix Closes-Bug: #2085126 Change-Id: I37c5462be8de39a7280208d55b64fc0430d0c584 --- .../dashboards/settings/user/forms.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/openstack_dashboard/dashboards/settings/user/forms.py b/openstack_dashboard/dashboards/settings/user/forms.py index 1c1f58dfaa..651091ea5b 100644 --- a/openstack_dashboard/dashboards/settings/user/forms.py +++ b/openstack_dashboard/dashboards/settings/user/forms.py @@ -13,6 +13,7 @@ # under the License. from datetime import datetime +import logging import string import zoneinfo @@ -29,6 +30,9 @@ from horizon import messages from horizon.utils import functions +LOG = logging.getLogger(__name__) + + class UserSettingsForm(forms.SelfHandlingForm): max_value = settings.API_RESULT_LIMIT language = forms.ChoiceField(label=_("Language")) @@ -82,8 +86,12 @@ class UserSettingsForm(forms.SelfHandlingForm): elif tz == "GMT": tz_name = _("GMT") else: - tz_label = babel.dates.get_timezone_location( - tz, locale=babel_locale) + try: + tz_label = babel.dates.get_timezone_location( + tz, locale=babel_locale) + except LookupError as e: + LOG.info('Failed to fetch locale for timezone: %s', e) + # Translators: UTC offset and timezone label tz_name = _("%(offset)s: %(label)s") % {"offset": utc_offset, "label": tz_label}