Coverage for app/venv/lib/python3.14/site-packages/weblate/trans/debug.py: 68%
24 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 07:15 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 07:15 +0000
1# Copyright © Michal Čihař <michal@weblate.org>
2#
3# SPDX-License-Identifier: GPL-3.0-or-later
5"""Wrapper to include useful information in error mails."""
7from __future__ import annotations
9from typing import TYPE_CHECKING
11from django.views.debug import SafeExceptionReporterFilter
13from weblate.utils.requirements import get_versions_list
15if TYPE_CHECKING: 15 ↛ 16line 15 didn't jump to line 16 because the condition on line 15 was never true
16 from weblate.auth.models import AuthenticatedHttpRequest
19class WeblateExceptionReporterFilter(SafeExceptionReporterFilter):
20 def get_post_parameters(self, request: AuthenticatedHttpRequest):
21 if hasattr(request, "META"): 21 ↛ 43line 21 didn't jump to line 43 because the condition on line 21 was always true
22 meta = request.META
23 if hasattr(request, "user"): 23 ↛ 26line 23 didn't jump to line 26 because the condition on line 23 was always true
24 meta["WEBLATE_USER"] = repr(request.user.username)
25 else:
26 meta["WEBLATE_USER"] = ""
27 if hasattr(request, "session") and "django_language" in request.session: 27 ↛ 28line 27 didn't jump to line 28 because the condition on line 27 was never true
28 meta["WEBLATE_LANGUAGE"] = request.session["django_language"]
29 else:
30 meta["WEBLATE_LANGUAGE"] = ""
32 try:
33 for name, _url, version in get_versions_list():
34 meta[f"WEBLATE_VERSION:{name}"] = version
35 except FileNotFoundError:
36 # Can happen during upgrade - the module is installed
37 # in newer version and different path
38 pass
39 except OSError:
40 # Out of memory or too many open files
41 pass
43 return super().get_post_parameters(request)