Added some safety checks and forced C locale for console printing
This commit is contained in:
@@ -28,10 +28,6 @@ import locale
|
||||
from datetime import datetime
|
||||
|
||||
matplotlib.use('Agg')
|
||||
try:
|
||||
locale.setlocale(locale.LC_TIME, locale.getdefaultlocale())
|
||||
except locale.Error:
|
||||
locale.setlocale(locale.LC_TIME, 'C')
|
||||
|
||||
|
||||
ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" # For paired peaks names
|
||||
@@ -54,6 +50,22 @@ KLIPPAIN_COLORS = {
|
||||
}
|
||||
|
||||
|
||||
# Set the best locale for time and date formating (generation of the titles)
|
||||
try:
|
||||
locale.setlocale(locale.LC_TIME, locale.getdefaultlocale())
|
||||
except locale.Error:
|
||||
locale.setlocale(locale.LC_TIME, 'C')
|
||||
|
||||
# Override the built-in print function to avoid problem in Klipper due to locale settings
|
||||
original_print = print
|
||||
def print_with_c_locale(*args, **kwargs):
|
||||
original_locale = locale.setlocale(locale.LC_ALL, None)
|
||||
locale.setlocale(locale.LC_ALL, 'C')
|
||||
original_print(*args, **kwargs)
|
||||
locale.setlocale(locale.LC_ALL, original_locale)
|
||||
print = print_with_c_locale
|
||||
|
||||
|
||||
######################################################################
|
||||
# Computation of the PSD graph
|
||||
######################################################################
|
||||
|
||||
Reference in New Issue
Block a user