mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
cfg: Allow loading multiple configuration files
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
9def9750c0
commit
2a38e60d1c
@ -136,7 +136,8 @@ def main():
|
||||
web_framework.init()
|
||||
|
||||
logger.info('FreedomBox Service (Plinth) version - %s', __version__)
|
||||
logger.info('Configuration loaded from file - %s', cfg.config_file)
|
||||
for config_file in cfg.config_files:
|
||||
logger.info('Configuration loaded from file - %s', config_file)
|
||||
logger.info('Script prefix - %s', cfg.server_dir)
|
||||
|
||||
module_loader.include_urls()
|
||||
|
||||
@ -47,7 +47,7 @@ box_name = 'FreedomBox'
|
||||
# Other globals
|
||||
develop = False
|
||||
|
||||
config_file = None
|
||||
config_files = []
|
||||
|
||||
|
||||
def get_fallback_config_paths():
|
||||
@ -78,13 +78,13 @@ def read(config_path=None, root_directory=None):
|
||||
# Ignore missing configuration files
|
||||
return
|
||||
|
||||
global config_file # pylint: disable-msg=invalid-name,global-statement
|
||||
config_file = config_path
|
||||
# Keep a note of configuration files read.
|
||||
config_files.append(config_path)
|
||||
|
||||
parser = configparser.ConfigParser(defaults={
|
||||
'root': os.path.realpath(root_directory),
|
||||
})
|
||||
parser.read(config_file)
|
||||
parser.read(config_path)
|
||||
|
||||
config_items = (
|
||||
('Path', 'root', 'string'),
|
||||
|
||||
@ -49,7 +49,7 @@ def test_read_primary_config_file(get_config_paths):
|
||||
|
||||
cfg.read()
|
||||
|
||||
assert cfg.config_file == expected_config_path
|
||||
assert cfg.config_files[-1] == expected_config_path
|
||||
assert cfg.root == expected_root_directory
|
||||
|
||||
|
||||
@ -60,7 +60,7 @@ def test_read_fallback_config_file():
|
||||
fallback_config_file = os.path.join(fallback_root, 'plinth.config')
|
||||
config_path, root_directory = cfg.get_fallback_config_paths()
|
||||
cfg.read(config_path, root_directory)
|
||||
assert cfg.config_file == fallback_config_file
|
||||
assert cfg.config_files[-1] == fallback_config_file
|
||||
assert cfg.root == fallback_root
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user