mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-11 15:52:21 -05:00
click (http://click.pocoo.org/) is used by flask to run its cli args. In removing flask_script (it's unmaintained), we had to migrate all our commands to use click. This is a change for the better in my eyes - you don't need to define the command in several places, and it makes managing options a bit easier. View diff with whitespace turned off unless you're a masochist.
25 lines
738 B
Python
25 lines
738 B
Python
from flask_migrate import Migrate, MigrateCommand
|
|
from app import (create_app, db, commands)
|
|
import os
|
|
|
|
default_env_file = '/home/ubuntu/environment'
|
|
environment = 'live'
|
|
|
|
if os.path.isfile(default_env_file):
|
|
with open(default_env_file, 'r') as environment_file:
|
|
environment = environment_file.readline().strip()
|
|
|
|
from app.config import configs
|
|
|
|
os.environ['NOTIFY_API_ENVIRONMENT'] = configs[environment]
|
|
|
|
application = create_app()
|
|
|
|
migrate = Migrate(application, db)
|
|
application.add_command('db', MigrateCommand)
|
|
application.add_command('purge_functional_test_data', commands.PurgeFunctionalTestDataCommand)
|
|
application.add_command('custom_db_script', commands.CustomDbScript)
|
|
|
|
if __name__ == '__main__':
|
|
manager.run()
|