mirror of
https://github.com/ChristianLight/tutor.git
synced 2024-12-12 14:17:46 +00:00
Improve output of environment upgrade
This commit is contained in:
parent
a2b098c1f0
commit
8cbab483ca
@ -76,22 +76,27 @@ def load(root):
|
|||||||
save_config(root, config)
|
save_config(root, config)
|
||||||
|
|
||||||
load_defaults(config)
|
load_defaults(config)
|
||||||
|
|
||||||
if not env.is_up_to_date(root):
|
if not env.is_up_to_date(root):
|
||||||
should_update_env = True
|
should_update_env = True
|
||||||
|
message = (
|
||||||
|
"The current environment stored at {} is not up-to-date: it is at "
|
||||||
|
"v{} while the 'tutor' binary is at v{}.".format(
|
||||||
|
env.base_dir(root), env.version(root), __version__
|
||||||
|
)
|
||||||
|
)
|
||||||
if os.isatty(sys.stdin.fileno()):
|
if os.isatty(sys.stdin.fileno()):
|
||||||
# Interactive mode: ask the user permission to proceed
|
# Interactive mode: ask the user permission to proceed
|
||||||
click.confirm(fmt.alert(
|
confirmation_msg = ("If you choose Y The environment will be "
|
||||||
"The current environment stored at {} is not up-to-date: it is at "
|
"upgraded now.\nAny change you might have made will be overwritten.\nProceed?")
|
||||||
"v{} while the 'tutor' binary is at v{}. The environment will be "
|
click.confirm(fmt.alert(message + '\n' + confirmation_msg), abort=True)
|
||||||
"upgraded now. Any change you might have made will be overwritten.".format(
|
|
||||||
env.base_dir(root), env.version(root), __version__
|
|
||||||
)
|
|
||||||
), abort=True)
|
|
||||||
elif os.environ.get('TUTOR_OVERWRITE_ENV'):
|
elif os.environ.get('TUTOR_OVERWRITE_ENV'):
|
||||||
pass # Non-interactive mode with environment variable authorizing us to go
|
pass # Non-interactive mode with environment variable authorizing us to go
|
||||||
else:
|
else:
|
||||||
raise click.Abort # Non-interactive mode with no authorization: abort
|
# Non-interactive mode with no authorization: abort
|
||||||
|
post_message = ("Set the TUTOR_OVERWRITE_ENV variable "
|
||||||
|
"to allow tutor to rewrite the environment"
|
||||||
|
"in a non-interactive run.")
|
||||||
|
raise click.UsageError(message + "\n" + post_message)
|
||||||
|
|
||||||
if should_update_env:
|
if should_update_env:
|
||||||
save_env(root, config)
|
save_env(root, config)
|
||||||
|
Loading…
Reference in New Issue
Block a user