pgreco / rpms / ipa

Forked from forks/areguera/rpms/ipa 4 years ago
Clone

Blame SOURCES/0087-schema-cache-Fallback-to-en_us-when-locale-is-not-av.patch

403b09
From 444907f8dd6d840bfbb97cf65ae754f0d816f706 Mon Sep 17 00:00:00 2001
403b09
From: David Kupka <dkupka@redhat.com>
403b09
Date: Thu, 18 Aug 2016 10:59:09 +0200
403b09
Subject: [PATCH] schema cache: Fallback to 'en_us' when locale is not
403b09
 available
403b09
403b09
https://fedorahosted.org/freeipa/ticket/6204
403b09
403b09
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
403b09
---
403b09
 ipaclient/remote_plugins/schema.py | 12 +++++++++---
403b09
 1 file changed, 9 insertions(+), 3 deletions(-)
403b09
403b09
diff --git a/ipaclient/remote_plugins/schema.py b/ipaclient/remote_plugins/schema.py
403b09
index 6fc70bf4b294badedd651e15b7e403cc40619f5c..8a77a15d489f067ab1312e863178458570403cc6 100644
403b09
--- a/ipaclient/remote_plugins/schema.py
403b09
+++ b/ipaclient/remote_plugins/schema.py
403b09
@@ -441,9 +441,15 @@ class Schema(object):
403b09
             self._dict[ns] = {}
403b09
             self._namespaces[ns] = _SchemaNameSpace(self, ns)
403b09
 
403b09
-        self._language = (
403b09
-            locale.setlocale(locale.LC_ALL, '').split('.')[0].lower()
403b09
-        )
403b09
+        # copy-paste from ipalib/rpc.py
403b09
+        try:
403b09
+            self._language = (
403b09
+                locale.setlocale(locale.LC_ALL, '').split('.')[0].lower()
403b09
+            )
403b09
+        except locale.Error:
403b09
+            # fallback to default locale
403b09
+            self._language = 'en_us'
403b09
+
403b09
         try:
403b09
             self._fingerprint = server_info['fingerprint']
403b09
             self._expiration = server_info['expiration']
403b09
-- 
403b09
2.7.4
403b09