From c5b0bdec65a9dd19cecb4b5e14ebed49226e12a8 Mon Sep 17 00:00:00 2001 From: Thorrak Date: Fri, 10 Apr 2020 16:33:10 -0400 Subject: [PATCH] Add check for packaging --- .../templates/gravity/gravity_tilt_test.html | 51 +++++++++++-------- gravity/tilt/tilt_tests.py | 14 ++++- gravity/views_tilt.py | 4 +- 3 files changed, 44 insertions(+), 25 deletions(-) diff --git a/gravity/templates/gravity/gravity_tilt_test.html b/gravity/templates/gravity/gravity_tilt_test.html index 3a3aface..394900ab 100644 --- a/gravity/templates/gravity/gravity_tilt_test.html +++ b/gravity/templates/gravity/gravity_tilt_test.html @@ -61,31 +61,40 @@

Python Packages

Note - The package list being tested below does not apply to installations on Windows.

- {% if has_python_packages %} -

All necessary python packages are installed

- {% else %} -

Several python packages are missing.

- {% endif %}{# has_python_packages #} + {% if has_packaging %} + {% if has_python_packages %} +

All necessary python packages are installed

+ {% else %} +

Several python packages are missing.

+ {% endif %}{# has_python_packages #} - - - - - - - - {% for test_result in python_test_results %} - - - - - - - {% endfor %} -
Package NameRequired VersionInstalled VersionOK?
{{ test_result.package }}{{ test_result.required_version }}{{ test_result.installed_version }}{% if test_result.ok %}OK{% else %}Not OK{% endif %}
+ + + + + + + + + {% for test_result in python_test_results %} + + + + + + + {% endfor %} +
Package NameRequired VersionInstalled VersionOK?
{{ test_result.package }}{{ test_result.required_version }}{{ test_result.installed_version }}{% if test_result.ok %}OK{% else %}Not OK{% endif %}
+ {% else %} +

Python 'packaging' module is not available - Test cannot run!

+

+ This is a fairly serious error, as it implies that your python packages are not being kept up-to-date. + Check the upgrade log to see what is happening. +

+ {% endif %}

Redis Connectivity

diff --git a/gravity/tilt/tilt_tests.py b/gravity/tilt/tilt_tests.py index 6e91f173..5540c396 100644 --- a/gravity/tilt/tilt_tests.py +++ b/gravity/tilt/tilt_tests.py @@ -1,6 +1,12 @@ import os, subprocess, sys import pkg_resources -from packaging import version + +try: + from packaging import version + has_packaging = True +except: + has_packaging = False + # This function is used ot check if an apt package is installed on Raspbian, Ubuntu, Debian, etc. @@ -45,7 +51,11 @@ def check_apt_packages() -> (bool, list): return all_packages_ok, test_results -def check_python_packages() -> (bool, list): +def check_python_packages() -> (bool, bool, list): + # Returns has_packaging, all_packages_ok, test_results[] + if not has_packaging: + return False, False, [] + if sys.platform == "darwin": # The MacOS support uses different packages from the support for Linux package_list = [ diff --git a/gravity/views_tilt.py b/gravity/views_tilt.py index a98e4503..56471daa 100644 --- a/gravity/views_tilt.py +++ b/gravity/views_tilt.py @@ -514,7 +514,7 @@ def gravity_tilt_test(request): apt_test_results = [] # Next, check the python packages - has_python_packages, python_test_results = tilt_tests.check_python_packages() + has_packaging, has_python_packages, python_test_results = tilt_tests.check_python_packages() # Then check Redis support redis_installed, able_to_connect_to_redis, redis_key_test = gravity_debug.try_redis() @@ -523,4 +523,4 @@ def gravity_tilt_test(request): context={'has_apt': has_apt, 'has_apt_packages': has_apt_packages, 'apt_test_results': apt_test_results, 'has_python_packages': has_python_packages, 'python_test_results': python_test_results, 'redis_installed': redis_installed, 'able_to_connect_to_redis': able_to_connect_to_redis, - 'redis_key_test': redis_key_test}) + 'redis_key_test': redis_key_test, 'has_packaging': has_packaging,})