6
0
mirror of https://github.com/ChristianLight/tutor.git synced 2024-12-12 14:17:46 +00:00

Make sure we don't hang in non-interactive environments

This commit is contained in:
Silvio Tomatis 2019-04-18 15:12:13 +02:00 committed by Régis Behmo
parent 08f157698f
commit a6a68881cd

View File

@ -1,5 +1,6 @@
import json
import os
import sys
import click
@ -77,6 +78,9 @@ def load(root):
load_defaults(config)
if not env.is_up_to_date(root):
should_update_env = True
if os.isatty(sys.stdin.fileno()):
# Interactive mode: ask the user permission to proceed
click.confirm(fmt.alert(
"The current environment stored at {} is not up-to-date: it is at "
"v{} while the 'tutor' binary is at v{}. The environment will be "
@ -84,7 +88,10 @@ def load(root):
env.base_dir(root), env.version(root), __version__
)
), abort=True)
should_update_env = True
elif os.environ.get('TUTOR_OVERWRITE_ENV'):
pass # Non-interactive mode with environment variable authorizing us to go
else:
raise click.Abort # Non-interactive mode with no authorization: abort
if should_update_env:
save_env(root, config)