Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/2082.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add OS version and NAV version to exception debug view
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ dependencies = [

"pyjwt>=2.6.0",

"distro",

# The following modules are really sub-requirements of Twisted, not of
# NAV directly. They may be optional from Twisted's point of view,
# but they are required for parts of the Twisted library that NAV uses:
Expand Down
12 changes: 12 additions & 0 deletions python/nav/django/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@

"""Django configuration wrapper around the NAV configuration files"""

import distro
import platform
import os
import sys
import copy
import warnings


from django.utils.log import DEFAULT_LOGGING

from nav.config import NAV_CONFIG, getconfig, find_config_dir
Expand Down Expand Up @@ -315,3 +318,12 @@
'JWT_ISSUERS': _issuers_setting,
'JWT_AUTH_HEADER_PREFIX': 'Bearer',
}

# Add NAV and OS-versions so they are added to exception views.
NAV_VERSION = nav.buildconf.VERSION
if platform.system() == "Linux":
OS_VERSION = f"{distro.name(pretty=True)} {distro.version()}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the documentation it says "If pretty is true, the version and codename are appended. (e.g. “CentOS Linux 7.1.1503 (Core)”)" (https://distro.readthedocs.io/en/latest/#distro.name)

Suggested change
OS_VERSION = f"{distro.name(pretty=True)} {distro.version()}"
OS_VERSION = distro.name(pretty=True)

elif platform.system() == "Darwin":
OS_VERSION = f"macOS {platform.mac_ver()[0]}"
else:
OS_VERSION = f"{platform.system()} {platform.release()} ({platform.version()})"
Loading