mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
module_loader: Specially load modules in development mode
Instead of the need to run './setup install' to install the module-enabled files into /etc/plinth/modules-enabled, pickup module configuration from app/data directories in development mode. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
925f7dd1c1
commit
3bedce47fd
@ -23,6 +23,7 @@ import django
|
|||||||
import importlib
|
import importlib
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import pathlib
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from plinth import cfg
|
from plinth import cfg
|
||||||
@ -150,17 +151,23 @@ def get_modules_to_load():
|
|||||||
if _modules_to_load is not None:
|
if _modules_to_load is not None:
|
||||||
return _modules_to_load
|
return _modules_to_load
|
||||||
|
|
||||||
modules = []
|
directory = pathlib.Path(cfg.config_dir) / 'modules-enabled'
|
||||||
module_directory = os.path.join(cfg.config_dir, 'modules-enabled')
|
files = list(directory.glob('*'))
|
||||||
|
if not files:
|
||||||
|
# './setup.py install' has not been executed yet. Pickup files to load
|
||||||
|
# from local module directories.
|
||||||
|
directory = pathlib.Path(__file__).parent
|
||||||
|
files = list(directory.glob('modules/*/data/etc/plinth/modules-enabled/*'))
|
||||||
|
|
||||||
# Omit hidden files
|
# Omit hidden files
|
||||||
file_names = [file_name
|
files = [
|
||||||
for file_name in os.listdir(module_directory)
|
file_ for file_ in files
|
||||||
if not file_name.startswith('.') and '.dpkg' not in file_name]
|
if not file_.name.startswith('.') and '.dpkg' not in file_.name
|
||||||
|
]
|
||||||
|
|
||||||
for file_name in file_names:
|
modules = []
|
||||||
full_file_name = os.path.join(module_directory, file_name)
|
for file_ in files:
|
||||||
with open(full_file_name, 'r') as file_handle:
|
with file_.open() as file_handle:
|
||||||
for line in file_handle:
|
for line in file_handle:
|
||||||
line = re.sub('#.*', '', line)
|
line = re.sub('#.*', '', line)
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user