mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-04-29 09:52:36 +02:00
Add errors to the output if they arise.
This commit is contained in:
parent
21c2ef1775
commit
95d4891857
1 changed files with 10 additions and 3 deletions
|
@ -67,18 +67,25 @@ class DeleteProject(Command):
|
||||||
def main():
|
def main():
|
||||||
QUIET_COMMANDS = ('generate_password_hash', 'generate-config')
|
QUIET_COMMANDS = ('generate_password_hash', 'generate-config')
|
||||||
|
|
||||||
|
exception = None
|
||||||
backup_stderr = sys.stderr
|
backup_stderr = sys.stderr
|
||||||
# Hack to divert stderr for commands generating content to stdout
|
# Hack to divert stderr for commands generating content to stdout
|
||||||
# to avoid confusing the user
|
# to avoid confusing the user
|
||||||
if len(sys.argv) > 1 and sys.argv[1] in QUIET_COMMANDS:
|
if len(sys.argv) > 1 and sys.argv[1] in QUIET_COMMANDS:
|
||||||
sys.stderr = open(os.devnull, 'w')
|
sys.stderr = open(os.devnull, 'w')
|
||||||
|
|
||||||
|
try:
|
||||||
app = create_app()
|
app = create_app()
|
||||||
Migrate(app, db)
|
Migrate(app, db)
|
||||||
|
except Exception as e:
|
||||||
|
exception = e
|
||||||
|
|
||||||
# Restore stderr (among other: to be able to display help)
|
# Restore stderr
|
||||||
sys.stderr = backup_stderr
|
sys.stderr = backup_stderr
|
||||||
|
|
||||||
|
if exception:
|
||||||
|
raise exception
|
||||||
|
|
||||||
manager = Manager(app)
|
manager = Manager(app)
|
||||||
manager.add_command('db', MigrateCommand)
|
manager.add_command('db', MigrateCommand)
|
||||||
manager.add_command('generate_password_hash', GeneratePasswordHash)
|
manager.add_command('generate_password_hash', GeneratePasswordHash)
|
||||||
|
|
Loading…
Reference in a new issue