-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature] Added page to show OpenWISP versions #273
Closes #273
- Loading branch information
Showing
14 changed files
with
142 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import platform | ||
from collections import OrderedDict | ||
|
||
import pkg_resources | ||
from django.conf import settings | ||
from django.utils.module_loading import import_string | ||
|
||
EXTRA_OPENWISP_PACKAGES = ['netdiff', 'netjsonconfig'] | ||
|
||
|
||
def get_installed_openwisp_packages(): | ||
dists = pkg_resources.working_set | ||
return { | ||
dist.key: dist.version | ||
for dist in dists | ||
if dist.key.startswith('openwisp') or dist.key in EXTRA_OPENWISP_PACKAGES | ||
} | ||
|
||
|
||
def get_openwisp_version(): | ||
try: | ||
return import_string('openwisp2.__openwisp_version__') | ||
except ImportError: | ||
return None | ||
|
||
|
||
def get_enabled_openwisp_modules(): | ||
enabled_packages = {} | ||
installed_packages = get_installed_openwisp_packages() | ||
extra_packages = {} | ||
for package, version in installed_packages.items(): | ||
if package in EXTRA_OPENWISP_PACKAGES: | ||
extra_packages[package] = version | ||
continue | ||
package_name = package.replace("-", "_") | ||
if package_name in settings.INSTALLED_APPS: | ||
enabled_packages[package] = version | ||
else: | ||
# check for sub-apps | ||
for app in settings.INSTALLED_APPS: | ||
if app.startswith(package_name + '.'): | ||
enabled_packages[package] = version | ||
break | ||
enabled_packages = OrderedDict(sorted(enabled_packages.items())) | ||
enabled_packages.update(OrderedDict(sorted(extra_packages.items()))) | ||
return enabled_packages | ||
|
||
|
||
def get_os_details(): | ||
uname = platform.uname() | ||
return { | ||
'os_version': uname.version, | ||
'kernel_version': uname.release, | ||
'hardware_platform': uname.machine, | ||
} |
18 changes: 18 additions & 0 deletions
18
openwisp_utils/admin_theme/templates/admin/openwisp_info.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{% extends "admin/base_site.html" %} | ||
{% load i18n %} | ||
|
||
{% block content %} | ||
{% if openwisp_version %} | ||
<h2>{% trans "OpenWISP Version" %}: {{ openwisp_version }}</h2> | ||
{% endif %} | ||
<h2>{% trans "Installed OpenWISP Modules" %}</h2> | ||
<ul> | ||
{% for name, version in enabled_openwisp_modules.items %} | ||
<li>{{ name }}: {{ version }}</li> | ||
{% endfor %} | ||
</ul> | ||
<h2>{% trans "OS Information" %}</h2> | ||
<p><strong>{% trans "OS version" %}:</strong> {{ system_info.os_version }}</p> | ||
<p><strong>{% trans "Kernel version" %}:</strong> {{ system_info.kernel_version }}</p> | ||
<p><strong>{% trans "Hardware platform" %}:</strong> {{ system_info.hardware_platform }}</p> | ||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__openwisp_version__ = '23.0.0a' |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters