mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-06 10:23:06 +03:00
Merge pull request #567 from Athanasius/fix/566-cli-params
EDMC.py: import re, fix version compare and report
This commit is contained in:
commit
cda7d9d3f4
12
EDMC.py
12
EDMC.py
@ -11,6 +11,7 @@ import os
|
|||||||
from os.path import dirname, getmtime, join
|
from os.path import dirname, getmtime, join
|
||||||
from time import time, sleep
|
from time import time, sleep
|
||||||
from xml.etree import ElementTree
|
from xml.etree import ElementTree
|
||||||
|
import re
|
||||||
|
|
||||||
import l10n
|
import l10n
|
||||||
l10n.Translations.install_dummy()
|
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
|
# quick and dirty version comparison assuming "strict" numeric only version numbers
|
||||||
def versioncmp(versionstring):
|
def versioncmp(versionstring):
|
||||||
return map(int, versionstring.split('.'))
|
return list(map(int, versionstring.split('.')))
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -67,9 +68,10 @@ try:
|
|||||||
lastversion = sorted(items, key=versioncmp)[-1]
|
lastversion = sorted(items, key=versioncmp)[-1]
|
||||||
if versioncmp(lastversion) > versioncmp(appversion):
|
if versioncmp(lastversion) > versioncmp(appversion):
|
||||||
latest = ' (%s is available)' % items[lastversion]
|
latest = ' (%s is available)' % items[lastversion]
|
||||||
except:
|
except Exception as e:
|
||||||
pass # Quietly suppress timeouts etc.
|
sys.stderr.write('Exception in version check: {}'.format(str(e)))
|
||||||
print('%.2f%s' % (float(''.join(appversion.split('.')[:3])) / 100, latest)) # just first three digits
|
#pass # Quietly suppress timeouts etc.
|
||||||
|
print(appversion)
|
||||||
sys.exit(EXIT_SUCCESS)
|
sys.exit(EXIT_SUCCESS)
|
||||||
|
|
||||||
if args.j:
|
if args.j:
|
||||||
@ -91,7 +93,7 @@ try:
|
|||||||
if __debug__:
|
if __debug__:
|
||||||
print('Invalid journal entry "%s"' % repr(line))
|
print('Invalid journal entry "%s"' % repr(line))
|
||||||
except Exception as e:
|
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)
|
sys.exit(EXIT_SYS_ERR)
|
||||||
|
|
||||||
if not monitor.cmdr:
|
if not monitor.cmdr:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user