mirror of
https://github.com/ChristianLight/tutor.git
synced 2025-01-12 09:51:08 +00:00
Simplify quickstart by using save.callback
This commit is contained in:
parent
b2fdaf604e
commit
daabbdc3b6
@ -37,7 +37,7 @@ class YamlParamType(click.ParamType):
|
||||
@click.option(
|
||||
"-s",
|
||||
"--set",
|
||||
"set_",
|
||||
"set_vars",
|
||||
type=YamlParamType(),
|
||||
multiple=True,
|
||||
metavar="KEY=VAL",
|
||||
@ -46,17 +46,18 @@ class YamlParamType(click.ParamType):
|
||||
@click.option(
|
||||
"-U",
|
||||
"--unset",
|
||||
"unset_vars",
|
||||
multiple=True,
|
||||
help="Remove a configuration value (can be used multiple times)",
|
||||
)
|
||||
@click.pass_obj
|
||||
def save(context, interactive, set_, unset):
|
||||
def save(context, interactive, set_vars, unset_vars):
|
||||
config, defaults = interactive_config.load_all(
|
||||
context.root, interactive=interactive
|
||||
)
|
||||
if set_:
|
||||
tutor_config.merge(config, dict(set_), force=True)
|
||||
for key in unset:
|
||||
if set_vars:
|
||||
tutor_config.merge(config, dict(set_vars), force=True)
|
||||
for key in unset_vars:
|
||||
config.pop(key, None)
|
||||
tutor_config.save_config_file(context.root, config)
|
||||
tutor_config.merge(config, defaults)
|
||||
|
@ -3,13 +3,12 @@ from textwrap import indent
|
||||
|
||||
import click
|
||||
|
||||
from . import compose
|
||||
from .context import Context
|
||||
from .. import config as tutor_config
|
||||
from .. import env as tutor_env
|
||||
from .. import fmt
|
||||
from .. import interactive as interactive_config
|
||||
from .. import utils
|
||||
from .. import fmt, utils
|
||||
from . import compose
|
||||
from .config import save as config_save_command
|
||||
from .context import Context
|
||||
|
||||
|
||||
# pylint: disable=too-few-public-methods
|
||||
@ -53,9 +52,7 @@ def quickstart(context, non_interactive, pullimages_):
|
||||
)
|
||||
|
||||
click.echo(fmt.title("Interactive platform configuration"))
|
||||
config = interactive_config.update(context.root, interactive=(not non_interactive))
|
||||
click.echo(fmt.title("Updating the current environment"))
|
||||
tutor_env.save(context.root, config)
|
||||
config_save_command.callback(interactive=(not non_interactive), set_vars=[], unset_vars=[])
|
||||
click.echo(fmt.title("Stopping any existing platform"))
|
||||
compose.stop.callback([])
|
||||
click.echo(fmt.title("HTTPS certificates generation"))
|
||||
@ -68,6 +65,7 @@ def quickstart(context, non_interactive, pullimages_):
|
||||
click.echo(fmt.title("Database creation and migrations"))
|
||||
compose.init.callback(limit=None)
|
||||
|
||||
config = tutor_config.load(context.root)
|
||||
fmt.echo_info(
|
||||
"""The Open edX platform is now running in detached mode
|
||||
Your Open edX platform is ready and can be accessed at the following urls:
|
||||
|
@ -231,7 +231,7 @@ def write_to(content, path):
|
||||
if isinstance(content, bytes):
|
||||
open_mode += "b"
|
||||
utils.ensure_file_directory_exists(path)
|
||||
with open(path, open_mode, encoding='utf8') as of:
|
||||
with open(path, open_mode, encoding="utf8") as of:
|
||||
of.write(content)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user