##// END OF EJS Templates
system-info: fixed calls to get locales on python3
super-admin -
r4982:4fcca1ba default
parent child Browse files
Show More
@@ -182,15 +182,26 b' def platform_type():'
182 def locale_info():
182 def locale_info():
183 import locale
183 import locale
184
184
185 def safe_get_locale(locale_name):
186 try:
187 locale.getlocale(locale_name)
188 except TypeError:
189 return f'FAILED_LOCALE_GET:{locale_name}'
190
185 value = dict(
191 value = dict(
186 locale_default=locale.getdefaultlocale(),
192 locale_default=locale.getdefaultlocale(),
187 locale_lc_all=locale.getlocale(locale.LC_ALL),
193 locale_lc_all=safe_get_locale(locale.LC_ALL),
194 locale_lc_ctype=safe_get_locale(locale.LC_CTYPE),
188 lang_env=os.environ.get('LANG'),
195 lang_env=os.environ.get('LANG'),
189 lc_all_env=os.environ.get('LC_ALL'),
196 lc_all_env=os.environ.get('LC_ALL'),
190 local_archive_env=os.environ.get('LOCALE_ARCHIVE'),
197 local_archive_env=os.environ.get('LOCALE_ARCHIVE'),
191 )
198 )
192 human_value = 'LANG: {}, locale LC_ALL: {}, Default locales: {}'.format(
199 human_value = \
193 value['lang_env'], value['locale_lc_all'], value['locale_default'])
200 f"LANG: {value['lang_env']}, \
201 locale LC_ALL: {value['locale_lc_all']}, \
202 locale LC_CTYPE: {value['locale_lc_ctype']}, \
203 Default locales: {value['locale_default']}"
204
194 return SysInfoRes(value=value, human_value=human_value)
205 return SysInfoRes(value=value, human_value=human_value)
195
206
196
207
@@ -238,7 +249,7 b' def uptime():'
238 human_value['boot_time'] = time_to_datetime(boot_time)
249 human_value['boot_time'] = time_to_datetime(boot_time)
239 human_value['uptime'] = age(time_to_datetime(boot_time), show_suffix=False)
250 human_value['uptime'] = age(time_to_datetime(boot_time), show_suffix=False)
240
251
241 human_value['text'] = u'Server started {}'.format(date_or_age)
252 human_value['text'] = 'Server started {}'.format(date_or_age)
242 return SysInfoRes(value=value, human_value=human_value)
253 return SysInfoRes(value=value, human_value=human_value)
243
254
244
255
General Comments 0
You need to be logged in to leave comments. Login now