mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-07-22 11:59:33 +00:00
help: Fix failing setup when manual directory is not available
- It is reported on the mailing list that first setup operation on the help app fails. The logs indicate that /usr/share/freedombox/manual directory is not present on the system. Although this situation does not occur on a normal installation, catch, log and ignore this error to be safe. - Also ensure that this static files component is added in post_init so that basic setup is not at all affected by it. Tests: - In the development directory, move doc/manual to doc/manual.bak. Observe that the error message is printed during initialization but the process continues. - With the manual directory properly restored, the full help manual is displayed properly with images. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
335a7f92cc
commit
03a805888d
@ -3,6 +3,7 @@
|
||||
FreedomBox app for help pages.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
@ -11,6 +12,8 @@ from django.utils.translation import pgettext_lazy
|
||||
from plinth import app as app_module
|
||||
from plinth import cfg, menu, web_server
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
app = None
|
||||
|
||||
|
||||
@ -54,12 +57,19 @@ class HelpApp(app_module.App):
|
||||
order=100)
|
||||
self.add(menu_item)
|
||||
|
||||
def post_init(self):
|
||||
"""Perform post initialization operations."""
|
||||
directory_map = {}
|
||||
langs = os.listdir(os.path.join(cfg.doc_dir, 'manual'))
|
||||
for lang in langs:
|
||||
manual_dir = os.path.join(cfg.doc_dir, 'manual', lang, 'images')
|
||||
manual_url = f'/help/manual/{lang}/images'
|
||||
directory_map[manual_url] = manual_dir
|
||||
try:
|
||||
langs = os.listdir(os.path.join(cfg.doc_dir, 'manual'))
|
||||
for lang in langs:
|
||||
manual_dir = os.path.join(cfg.doc_dir, 'manual', lang,
|
||||
'images')
|
||||
manual_url = f'/help/manual/{lang}/images'
|
||||
directory_map[manual_url] = manual_dir
|
||||
except FileNotFoundError:
|
||||
logger.error('Unable to find manual directory. Ensure that '
|
||||
'freedombox-doc-* packages are installed')
|
||||
|
||||
static_files = web_server.StaticFiles('static-files-help',
|
||||
directory_map)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user