Skip to content

Commit

Permalink
Add check for packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
thorrak committed Apr 10, 2020
1 parent ca5f906 commit c5b0bde
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 25 deletions.
51 changes: 30 additions & 21 deletions gravity/templates/gravity/gravity_tilt_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,31 +61,40 @@ <h3>Python Packages</h3>
<b>Note - </b> The package list being tested below does not apply to installations on Windows.
</p>

{% if has_python_packages %}
<h4>All necessary python packages are installed</h4>
{% else %}
<h4 style="color: darkred">Several python packages are missing. </h4>
{% endif %}{# has_python_packages #}
{% if has_packaging %}

{% if has_python_packages %}
<h4>All necessary python packages are installed</h4>
{% else %}
<h4 style="color: darkred">Several python packages are missing. </h4>
{% endif %}{# has_python_packages #}

<table class="table table-hover">
<tr>
<td>Package Name</td>
<td>Required Version</td>
<td>Installed Version</td>
<td>OK?</td>
</tr>

{% for test_result in python_test_results %}
<tr>
<td>{{ test_result.package }}</td>
<td>{{ test_result.required_version }}</td>
<td>{{ test_result.installed_version }}</td>
<td>{% if test_result.ok %}OK{% else %}Not OK{% endif %}</td>
</tr>
{% endfor %}
</table>
<table class="table table-hover">
<tr>
<td>Package Name</td>
<td>Required Version</td>
<td>Installed Version</td>
<td>OK?</td>
</tr>

{% for test_result in python_test_results %}
<tr>
<td>{{ test_result.package }}</td>
<td>{{ test_result.required_version }}</td>
<td>{{ test_result.installed_version }}</td>
<td>{% if test_result.ok %}OK{% else %}Not OK{% endif %}</td>
</tr>
{% endfor %}
</table>
{% else %}
<h4>Python 'packaging' module is not available - Test cannot run!</h4>
<p>
This is a fairly serious error, as it implies that your python packages are not being kept up-to-date.
Check the <a href="{% url "get_app_log" "text" "upgrade" "stderr" %}">upgrade log</a> to see what is happening.
</p>

{% endif %}

<h3>Redis Connectivity</h3>

Expand Down
14 changes: 12 additions & 2 deletions gravity/tilt/tilt_tests.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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 = [
Expand Down
4 changes: 2 additions & 2 deletions gravity/views_tilt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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,})

0 comments on commit c5b0bde

Please sign in to comment.