Unify configuration requirements

This commit is contained in:
Piotr F. Mieszkowski 2024-01-08 22:14:56 +01:00
parent 276e0d0cd4
commit cd67b0934e
3 changed files with 14 additions and 12 deletions

View file

@ -37,7 +37,7 @@ LOG = logging.getLogger('lacre.py')
def main():
with time_logger('Message delivery', LOG):
missing_params = conf.validate_config(additional=conf.SCRIPT_REQUIRED)
missing_params = conf.validate_config()
config_file = conf.config_source()
if missing_params:

View file

@ -18,7 +18,10 @@ lacre.init_logging(conf.get_item('logging', 'config'))
import lacre.repositories as repo
import lacre.dbschema as db
LOG = logging.getLogger(__name__)
if __name__ == '__main__':
LOG = logging.getLogger('lacre.admin')
else:
LOG = logging.getLogger(__name__)
def _no_database():
@ -86,7 +89,10 @@ def sub_import(args):
def main():
conf.validate_config(additional=conf.SCRIPT_REQUIRED)
missing = conf.validate_config()
if missing:
LOG.error('Missing configuration parameters: %s', missing)
sys.exit(lacre.EX_CONFIG)
general_conf = conf.config_source()
log_conf = conf.get_item('logging', 'config')

View file

@ -21,16 +21,12 @@ MANDATORY_CONFIG_ITEMS = [("relay", "host"),
("relay", "port"),
("daemon", "host"),
("daemon", "port"),
("gpg", "keyhome")]
("gpg", "keyhome"),
('database', 'enabled'),
('database', 'url'),
('database', 'pooling_mode')]
SCRIPT_REQUIRED = [('database', 'enabled'),
('database', 'url'),
('database', 'pooling_mode')]
CRON_REQUIRED = [('database', 'enabled'),
('database', 'url'),
('database', 'pooling_mode'),
('cron', 'mail_templates')]
CRON_REQUIRED = [('cron', 'mail_templates')]
# Global dict to keep configuration parameters. It's hidden behind several
# utility functions to make it easy to replace it with ConfigParser object in