From 7e5e18fd6e4bc241daf42a67a2941dec68b441b5 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Fri, 22 Dec 2017 13:10:40 -0500 Subject: [PATCH] Only prompt for upgrades if there's a TTY & mark 1.1.0 (#537) --- CHANGELOG.md | 1 + CTFd/__init__.py | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27213988..c445ab44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ * SMTP email connections take priority over mailgun settings now. The opposite used to be true. * The JavaScript `submitkey()` function now takes an optional callback. * `utils.get_config()` no longer looks at `app.config` values. Instead use `utils.get_app_config()`. +* Only prompt about upgrades when running with a TTY. 1.0.5 / 2017-10-25 diff --git a/CTFd/__init__.py b/CTFd/__init__.py index 5a2f82cb..bc29e5b4 100644 --- a/CTFd/__init__.py +++ b/CTFd/__init__.py @@ -17,7 +17,7 @@ if sys.version_info[0] < 3: reload(sys) sys.setdefaultencoding("utf-8") -__version__ = '1.1.0a1' +__version__ = '1.1.0' class CTFdFlask(Flask): @@ -64,14 +64,17 @@ class ThemeLoader(FileSystemLoader): def confirm_upgrade(): - print("/*\\ CTFd has updated and must update the database! /*\\") - print("/*\\ Please backup your database before proceeding! /*\\") - print("/*\\ CTFd maintainers are not responsible for any data loss! /*\\") - if input('Run database migrations (Y/N)').lower().strip() == 'y': - return True + if sys.stdin.isatty(): + print("/*\\ CTFd has updated and must update the database! /*\\") + print("/*\\ Please backup your database before proceeding! /*\\") + print("/*\\ CTFd maintainers are not responsible for any data loss! /*\\") + if input('Run database migrations (Y/N)').lower().strip() == 'y': + return True + else: + print('/*\\ Ignored database migrations... /*\\') + return False else: - print('/*\\ Ignored database migrations... /*\\') - return False + return True def run_upgrade():