aboutsummaryrefslogtreecommitdiff
path: root/ihatemoney/manage.py
diff options
context:
space:
mode:
authorJocelynDelalande <JocelynDelalande@users.noreply.github.com>2017-12-27 17:28:18 +0100
committerAlexis Metaireau <alexis@notmyidea.org>2017-12-27 17:28:18 +0100
commit1c9120e68bc00f0a4e4c8776a0360939331f8e73 (patch)
treef2d5a5281c40dd0fcd134a3b55316f9c3b2dd511 /ihatemoney/manage.py
parentf2a53eb1e3e9b4be1673d34069138d3da6f6caa9 (diff)
downloadihatemoney-mirror-1c9120e68bc00f0a4e4c8776a0360939331f8e73.zip
ihatemoney-mirror-1c9120e68bc00f0a4e4c8776a0360939331f8e73.tar.gz
ihatemoney-mirror-1c9120e68bc00f0a4e4c8776a0360939331f8e73.tar.bz2
Silent stderr output during app init for some commands (#293)
Avoid confusing the user for the commands outputing text to the user. fix #277
Diffstat (limited to 'ihatemoney/manage.py')
-rwxr-xr-xihatemoney/manage.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/ihatemoney/manage.py b/ihatemoney/manage.py
index c1821c5..797e6c4 100755
--- a/ihatemoney/manage.py
+++ b/ihatemoney/manage.py
@@ -3,6 +3,7 @@
import os
import pkgutil
import random
+import sys
from getpass import getpass
from flask_script import Manager, Command, Option
@@ -56,9 +57,20 @@ class ConfigTemplate(Command):
def main():
+ QUIET_COMMANDS = ('generate_password_hash', 'generate-config')
+
+ backup_stderr = sys.stderr
+ # Hack to divert stderr for commands generating content to stdout
+ # to avoid confusing the user
+ if len(sys.argv) > 1 and sys.argv[1] in QUIET_COMMANDS:
+ sys.stderr = open(os.devnull, 'w')
+
app = create_app()
Migrate(app, db)
+ # Restore stderr (among other: to be able to display help)
+ sys.stderr = backup_stderr
+
manager = Manager(app)
manager.add_command('db', MigrateCommand)
manager.add_command('generate_password_hash', GeneratePasswordHash)