Skip to content

Commit

Permalink
Python feature flag compat (#1061)
Browse files Browse the repository at this point in the history
Some checks to ensure all platforms load with stats feature flag

- remove use of deprecated pkg_resources
- check stats enabled before loading the StatsViewPage and route
- remove matplotlib from el9 spec
  • Loading branch information
jw3 authored Dec 31, 2024
1 parent c3db148 commit 1baaf50
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
9 changes: 0 additions & 9 deletions .github/rpm-matrix.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
{
"props": [
{
"platform": "fedora",
"dist": "fc42",
"spec": "fapolicy-analyzer.spec",
"image": "registry.fedoraproject.org/fedora:42",
"chroot": "fedora-rawhide-x86_64",
"version": "42",
"prerelease": true
},
{
"platform": "fedora",
"dist": "fc41",
Expand Down
6 changes: 3 additions & 3 deletions fapolicy_analyzer/ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from typing import Dict, Optional, Sequence, Tuple

import gi
import pkg_resources

from fapolicy_analyzer.ui.strings import (
RESOURCE_LOAD_FAILURE_DIALOG_ADD_TEXT,
RESOURCE_LOAD_FAILURE_DIALOG_TEXT,
Expand All @@ -37,8 +37,8 @@

DOMAIN = "fapolicy_analyzer"
locale.setlocale(locale.LC_ALL, locale.getlocale())
locale_path = pkg_resources.resource_filename("fapolicy_analyzer", "locale")
locale.bindtextdomain(DOMAIN, locale_path)
locale_path = resources.path("fapolicy_analyzer", "locale")
locale.bindtextdomain(DOMAIN, str(locale_path))
locale.textdomain(DOMAIN)

_RESOURCES: Dict[str, str] = {}
Expand Down
12 changes: 9 additions & 3 deletions fapolicy_analyzer/ui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import logging
import os
import json
from fapolicy_analyzer.ui.stats import StatsViewPage

from locale import gettext as _
from os import getenv, geteuid, path
from threading import Thread
Expand All @@ -27,6 +27,10 @@

import fapolicy_analyzer.ui.strings as strings
from fapolicy_analyzer import System, is_audit_available, is_stats_available

if is_stats_available():
from fapolicy_analyzer.ui.stats import StatsViewPage

from fapolicy_analyzer import __version__ as app_version
from fapolicy_analyzer.ui import get_resource
from fapolicy_analyzer.ui.action_toolbar import ActionToolbar
Expand Down Expand Up @@ -82,8 +86,10 @@ def router(page: PAGE_SELECTION, *data) -> UIPage:
PAGE_SELECTION.PROFILER: ProfilerPage,
PAGE_SELECTION.CONFIG: ConfigAdminPage,
PAGE_SELECTION.TRUST_FILTER: TrustFilterAdminPage,
PAGE_SELECTION.STATS_VIEW: StatsViewPage,
}.get(page, RulesAdminPage)
}
if is_stats_available():
route[PAGE_SELECTION.STATS_VIEW] = StatsViewPage
route = route.get(page, route)
return route(*data)


Expand Down
1 change: 0 additions & 1 deletion scripts/srpm/fapolicy-analyzer.el9.spec
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ Requires: python3-more-itertools
Requires: python3-rx
Requires: python3-importlib-metadata
Requires: python3-toml
Requires: python3-matplotlib-gtk3

Requires: gtk3
Requires: gtksourceview3
Expand Down

0 comments on commit 1baaf50

Please sign in to comment.