From f08d60d9b139648cfdc7c23cdf190b90e4d41e81 Mon Sep 17 00:00:00 2001 From: A_D Date: Sun, 26 Jul 2020 18:57:23 +0200 Subject: [PATCH] revert using json.dump windows encodings dont like the weird characters --- EDMC.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/EDMC.py b/EDMC.py index 739a4a24..2d2eb476 100755 --- a/EDMC.py +++ b/EDMC.py @@ -91,10 +91,8 @@ def main(): newversion: Optional[EDMCVersion] = updater.check_appcast() if newversion: print(f'{appversion} ({newversion.title!r} is available)') - else: print(appversion) - sys.exit(EXIT_SUCCESS) if args.j: @@ -106,9 +104,7 @@ def main(): # Get state from latest Journal file try: logdir = config.get('journaldir') or config.default_journal_dir - logfiles = sorted( - (x for x in os.listdir(logdir) if JOURNAL_RE.search(x)), key=lambda x: x.split('.')[1:] - ) + logfiles = sorted((x for x in os.listdir(logdir) if JOURNAL_RE.search(x)), key=lambda x: x.split('.')[1:]) logfile = join(logdir, logfiles[-1]) @@ -116,7 +112,6 @@ def main(): for line in loghandle: try: monitor.parse_entry(line) - except Exception: if __debug__: print(f'Invalid journal entry {line!r}') @@ -189,8 +184,9 @@ def main(): # stuff we can do when not docked if args.d: - with open(args.d, 'w') as f: - json.dump(data, f, ensure_ascii=False, indent=2, sort_keys=True, separators=(',', ': ')) + out = json.dumps(data, ensure_ascii=False, indent=2, sort_keys=True, separators=(',', ': ')) + with open(args.d, 'wb') as f: + f.write(out.encode("utf-8")) if args.a: loadout.export(data, args.a)