From 3ff77c3c54dea4bf36d957cd2dbd5b1b02dcb094 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Tue, 7 Jul 2020 19:00:06 +0100 Subject: [PATCH] EDMC.py: import re, fix version compare and report * I neglected to `import re` when I changed the Journal file name check. * `map` isn't comparable in Python 3.7, need to `list()` it as well. * Just print the full `appversion`. The old code was assuming that none of A, B, C, D in A.B.C.D would be two or more digits. close #566 --- EDMC.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/EDMC.py b/EDMC.py index 60687e90..2aaeee8c 100755 --- a/EDMC.py +++ b/EDMC.py @@ -11,6 +11,7 @@ import os from os.path import dirname, getmtime, join from time import time, sleep from xml.etree import ElementTree +import re import l10n l10n.Translations.install_dummy() @@ -36,7 +37,7 @@ EXIT_SUCCESS, EXIT_SERVER, EXIT_CREDENTIALS, EXIT_VERIFICATION, EXIT_LAGGING, EX # quick and dirty version comparison assuming "strict" numeric only version numbers def versioncmp(versionstring): - return map(int, versionstring.split('.')) + return list(map(int, versionstring.split('.'))) try: @@ -67,9 +68,10 @@ try: lastversion = sorted(items, key=versioncmp)[-1] if versioncmp(lastversion) > versioncmp(appversion): latest = ' (%s is available)' % items[lastversion] - except: - pass # Quietly suppress timeouts etc. - print('%.2f%s' % (float(''.join(appversion.split('.')[:3])) / 100, latest)) # just first three digits + except Exception as e: + sys.stderr.write('Exception in version check: {}'.format(str(e))) + #pass # Quietly suppress timeouts etc. + print(appversion) sys.exit(EXIT_SUCCESS) if args.j: @@ -91,7 +93,7 @@ try: if __debug__: print('Invalid journal entry "%s"' % repr(line)) except Exception as e: - sys.stderr.write("Can't read Journal file: %s\n" % str(e).encode('ascii', 'replace')) + sys.stderr.write("Can't read Journal file: {}\n".format(str(e))) sys.exit(EXIT_SYS_ERR) if not monitor.cmdr: