mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-04-28 17:32:38 +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():
|
||||
QUIET_COMMANDS = ('generate_password_hash', 'generate-config')
|
||||
|
||||
exception = None
|
||||
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)
|
||||
try:
|
||||
app = create_app()
|
||||
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
|
||||
|
||||
if exception:
|
||||
raise exception
|
||||
|
||||
manager = Manager(app)
|
||||
manager.add_command('db', MigrateCommand)
|
||||
manager.add_command('generate_password_hash', GeneratePasswordHash)
|
||||
|
|
Loading…
Reference in a new issue