Merge pull request #441 from Kozea/run_split

Split the main run function to allow the use of radicale serving programatically.
This commit is contained in:
Guillaume Ayoub 2016-07-05 18:06:27 +02:00 committed by GitHub
commit 828d43a305
2 changed files with 10 additions and 1 deletions

View File

@ -107,6 +107,11 @@ def run():
if not configuration_found:
logger.warning("Configuration file '%s' not found" % options.config)
serve(configuration, logger)
def serve(configuration, logger):
"""Serve radicale from configuration"""
# Fork if Radicale is launched as daemon
if configuration.getboolean("server", "daemon"):
# Check and create PID file in a race-free manner

View File

@ -65,12 +65,16 @@ INITIAL_CONFIG = {
"mask_passwords": "True"}}
def load(paths=()):
def load(paths=(), extra_config=None):
config = ConfigParser()
for section, values in INITIAL_CONFIG.items():
config.add_section(section)
for key, value in values.items():
config.set(section, key, value)
if extra_config:
for section, values in extra_config.items():
for key, value in values.items():
config.set(section, key, value)
for path in paths:
if path:
config.read(path)