From 60aa016734970ef31cce784306f5cbac53bbbe22 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Sat, 6 Nov 2021 21:17:48 +0400 Subject: [PATCH] Handling of missing required dependency during dependency check --- cps/__init__.py | 2 +- cps/about.py | 1 - cps/dep_check.py | 17 ++++++++++------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/cps/__init__.py b/cps/__init__.py index a1a721c7..118b46ff 100644 --- a/cps/__init__.py +++ b/cps/__init__.py @@ -129,7 +129,7 @@ def create_app(): web_server.stop(True) sys.exit(7) for res in dependency_check() + dependency_check(True): - log.info('*** "{}" version does not fit the requirements. Should: {}, Found: {}, please consider updating. ***' + log.info('*** "{}" version does not fit the requirements. Should: {}, Found: {}, please consider installing required version ***' .format(res['name'], res['target'], res['found'])) diff --git a/cps/about.py b/cps/about.py index 54e29d55..ba5a99af 100644 --- a/cps/about.py +++ b/cps/about.py @@ -117,7 +117,6 @@ else: Jinja2=jinja2.__version__, pySqlite = sqlite3.version, SQLite = sqlite3.sqlite_version, - Unidecode=unidecode_version, ) _VERSIONS.update(ret) _VERSIONS.update(uploader.get_versions(False)) diff --git a/cps/dep_check.py b/cps/dep_check.py index 1877576a..12436d1d 100644 --- a/cps/dep_check.py +++ b/cps/dep_check.py @@ -38,11 +38,7 @@ def load_dependencys(optional=False): except ImportNotFound: if optional: continue - '''else: - return [{'name':res.group(1), - 'target': "available", - 'found': "Not available" - }]''' + dep_version = "not installed" deps.append([dep_version, res.group(1), res.group(2), res.group(3), res.group(4), res.group(5)]) return deps @@ -51,12 +47,19 @@ def dependency_check(optional=False): d = list() deps = load_dependencys(optional) for dep in deps: - dep_version_int = [int(x) for x in dep[0].split('.')] - low_check = [int(x) for x in dep[3].split('.')] try: + dep_version_int = [int(x) for x in dep[0].split('.')] + low_check = [int(x) for x in dep[3].split('.')] high_check = [int(x) for x in dep[5].split('.')] except AttributeError: high_check = None + except ValueError: + d.append({'name': dep[1], + 'target': "available", + 'found': "Not available" + }) + continue + if dep[2].strip() == "==": if dep_version_int != low_check: d.append({'name': dep[1],