Example #1
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# inventory-manager (c) Adam Dorfman

import sys
import traceback
sys.path.insert(0, '.')

from flask.ext.script import Manager, Shell, Server
from flask.ext.migrate import Migrate, MigrateCommand
import alembic
import alembic.config

from inventory_manager import create_app, db, security, models
app = create_app()


def _make_context():
    return dict(app=app, db=db, user_datastore=security.datastore)

migrate = Migrate(app, db, directory="inventory_manager/migrations")

manager = Manager(app)
manager.add_command("shell", Shell(make_context=_make_context))
manager.add_command("runserver", Server(port=app.config['PORT']))
manager.add_command("publicserver", Server(port=app.config['PORT'], host="0.0.0.0"))
manager.add_command('db', MigrateCommand)


@manager.option('-e', '--email', help='email address')
@manager.option('-p', '--password', help='password')
 def create_app(self):
     self.app = create_app()
     self.app.config['WTF_CSRF_ENABLED'] = False
     self.db = db
     return self.app