File: do-not-import-enabled-if-no-plugins.patch

package info (click to toggle)
horizon 3%3A25.3.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 32,900 kB
  • sloc: python: 100,002; javascript: 49,478; sh: 453; makefile: 79
file content (57 lines) | stat: -rw-r--r-- 1,972 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Description: Do not import enabled if no plugins
 Without this patch, removing the *last* plugin form Horizon will crash
 collect static with:
  File "/usr/lib/python3/dist-packages/openstack_dashboard/settings.py", line 31, in <module>
    from openstack_dashboard.local import enabled as local_enabled
  ImportError: cannot import name 'enabled' from 'openstack_dashboard.local' (/usr/lib/python3/dist-packages/openstack_dashboard/local/__init__.py)
Author: Thomas Goirand <zigo@debian.org>
Bug-Debian: https://bugs.debian.org/1108931
Forwarded: https://review.opendev.org/c/openstack/horizon/+/954568
Last-Update: 2025-07-10

--- horizon-25.3.0.orig/openstack_dashboard/settings.py
+++ horizon-25.3.0/openstack_dashboard/settings.py
@@ -28,7 +28,10 @@ from horizon.utils.escape import monkeyp
 
 from openstack_dashboard import enabled
 from openstack_dashboard import exceptions
-from openstack_dashboard.local import enabled as local_enabled
+try:
+    from openstack_dashboard.local import enabled as local_enabled
+except ImportError:
+    pass
 from openstack_dashboard import theme_settings
 from openstack_dashboard.utils import config
 from openstack_dashboard.utils import settings as settings_utils
@@ -348,14 +351,23 @@ settings_utils.find_static_files(HORIZON
                                  THEME_COLLECTION_DIR, ROOT_PATH)
 
 INSTALLED_APPS = list(INSTALLED_APPS)  # Make sure it's mutable
-settings_utils.update_dashboards(
-    [
-        enabled,
-        local_enabled,
-    ],
-    HORIZON_CONFIG,
-    INSTALLED_APPS,
-)
+try:
+    settings_utils.update_dashboards(
+        [
+            enabled,
+            local_enabled,
+        ],
+        HORIZON_CONFIG,
+        INSTALLED_APPS,
+    )
+except NameError:
+    settings_utils.update_dashboards(
+        [
+            enabled,
+        ],
+        HORIZON_CONFIG,
+        INSTALLED_APPS,
+    )
 INSTALLED_APPS[0:0] = ADD_INSTALLED_APPS
 
 # Include xstatic_modules specified in plugin