From bd8d45054245666321ea1c7360d86504aefa9865 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Thu, 23 Jun 2022 16:12:13 +0300 Subject: [PATCH] UTF-8 check inserted into databasereset --- databaseReset.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/databaseReset.py b/databaseReset.py index c2a0d9bd..1d8427bc 100644 --- a/databaseReset.py +++ b/databaseReset.py @@ -4,6 +4,7 @@ import time import timeit import json import resource +import locale import settings """ Command-line utility for loading cave data files into troggle's database. @@ -353,6 +354,16 @@ if __name__ == "__main__": print("Do not run as root or using sudo - file permissions for cache files and logs will break") print("Aborting run.") exit() + + if sys.getfilesystemencoding() != "utf-8": + print("UTF-8 is NOT the default file encoding. You must fix this.") + print(f'- {sys.getdefaultencoding()=}') + print(f'- {sys.getfilesystemencoding()=}') + print(f'- {locale.getdefaultlocale()=}') + print(f'- {locale.getpreferredencoding()=}') + print("Aborting run.") + exit() + if len(sys.argv)>2: runlabel = sys.argv[len(sys.argv)-1] else: