1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-14 16:27:13 +03:00

Made sure to handle non-utf8 locales

This commit is contained in:
A_D 2020-12-02 15:57:42 +02:00
parent 52d39dc5fd
commit 977e62188a
No known key found for this signature in database
GPG Key ID: 4BE9EB7DF45076C4

View File

@ -173,7 +173,11 @@ sys.path: {sys.path}'''
if args.j:
logger.debug('Import and collate from JSON dump')
# Import and collate from JSON dump
data = json.load(open(args.j))
try:
data = json.load(open(args.j))
except UnicodeDecodeError:
data = json.load(open(args.j, encoding='utf-8'))
config.set('querytime', int(getmtime(args.j)))
else:
@ -188,7 +192,7 @@ sys.path: {sys.path}'''
logfile = join(logdir, logfiles[-1])
logger.debug(f'Using logfile "{logfile}"')
with open(logfile, 'r') as loghandle:
with open(logfile, 'r', encoding='utf-8') as loghandle:
for line in loghandle:
try:
monitor.parse_entry(line)