Exemple #1
0
def _init_db(app):
    db.init_app(app)

    migrate = Migrate()
    migrate.init_app(app, db)

    with app.app_context():
        db.create_all()
import os
from app import create_app, db
from app.models import User
from flask.ext.script import Manager, Shell
from flask.ext.migrate import Migrate, MigrateCommand

basedir = os.path.abspath(os.path.dirname(__file__))

app = create_app('testing')
manager = Manager(app)
migrate = Migrate()
migrate.init_app(app, db, directory=os.path.join(basedir, 'migrations/'))

def make_shell_context():
    return dict(app=app, db=db, User=User)
manager.add_command("shell", Shell(make_context=make_shell_context))
manager.add_command('db', MigrateCommand)

@manager.command
def test():
    import unittest
    tests = unittest.TestLoader().discover('tests') 
    unittest.TextTestRunner(verbosity=3).run(tests)

if __name__ == '__main__': 
    manager.run()
Exemple #3
0
from flask.ext.migrate import MigrateCommand, Migrate
from flask.ext.script import Manager
from factory import create_app

from app import app
from libs.db import db

migrate = Migrate()
migrate.init_app(app, db)

manager = Manager(app)

manager.add_command('db', MigrateCommand)


if __name__ == '__main__':
    manager.run()
Exemple #4
0
import os
from datetime import datetime

from flask.ext.script import Manager
from flask.ext.migrate import Migrate, MigrateCommand

from web import app, db
from dbupdate import (update_ratebeer as rb_update, update_pol_beers,
                      update_pol_shops, update_pol_stock, update_adminareas)

manager = Manager(app)

DIR = os.path.dirname(os.path.realpath(__file__))

migrate = Migrate()
migrate.init_app(app, db, directory=DIR + '/alembic')
manager.add_command('db', MigrateCommand)


def log_write(message):
    with open('log.txt', 'a') as logfile:
        logfile.write('%s %s\n' % (message, datetime.now()))


@manager.command
def update_ratebeer():
    print 'Importing data from ratebeer'
    rb_update(app.config.get('SQLALCHEMY_DATABASE_URI', None))


@manager.command
Exemple #5
0
from app.config.config import app, db, server
from flask.ext.script import Manager
from flask.ext.migrate import Migrate, MigrateCommand
from app.manager.seed import seed

migrate = Migrate(app, db)

migrate.init_app(app, db, directory='../../migrations')

manager = Manager(app)

manager.add_command("runserver", server)

manager.add_command('db', MigrateCommand)

manager.add_command('seed', seed)
Exemple #6
0
from app.config.config import app, db, server
from flask.ext.script import Manager
from flask.ext.migrate import Migrate, MigrateCommand
from app.manager.db import CreateDatabase
from app.manager.load_fixtures import LoadFixtures
from app.manager.add_posts import FacebookPosts
from app.manager.facebook import FacebookData
from app.manager.seed import seed
from app.manager.test import test
from app.manager.fb_to_amazon import fb_to_amazon

migrate = Migrate(app, db)

migrate.init_app(app, db, directory='../../migrations')

manager = Manager(app)

manager.add_command("runserver", server)
manager.add_command('db', MigrateCommand)
manager.add_command('createDb', CreateDatabase)
manager.add_command('loadFixtures', LoadFixtures)
manager.add_command('addPosts', FacebookPosts)
manager.add_command('getFixtures', FacebookData)
manager.add_command('seed', seed)
manager.add_command('test', test)
manager.add_command('fb_to_amazon', fb_to_amazon)
Exemple #7
0
import os
from datetime import datetime

from flask.ext.script import Manager
from flask.ext.migrate import Migrate, MigrateCommand

from web import app, db
from dbupdate import (update_ratebeer as rb_update, update_pol_beers,
                      update_pol_shops, update_pol_stock, update_adminareas)

manager = Manager(app)

DIR = os.path.dirname(os.path.realpath(__file__))

migrate = Migrate()
migrate.init_app(app, db, directory=DIR + '/alembic')
manager.add_command('db', MigrateCommand)


def log_write(message):
    with open('log.txt', 'a') as logfile:
        logfile.write('%s %s\n' % (message, datetime.now()))


@manager.command
def update_ratebeer():
    print 'Importing data from ratebeer'
    rb_update(app.config.get('SQLALCHEMY_DATABASE_URI', None))


@manager.command
Exemple #8
0
from app.database import db
from app import models
from app import create_app
from flask_s3 import FlaskS3
import flask_s3
import logging, logging.config, yaml
import os

from flask.ext.cors import CORS

app = create_app()

manager = Manager(app)
migrate = Migrate()
cors = CORS(app)
migrate.init_app(app, db, directory="./migrations")
s3 = FlaskS3(app)


def _make_context():
    return dict(app=current_app, db=db, models=models)


server = Server(host="0.0.0.0", port=80)
manager.add_option('-c', '--config', dest='config', required=False)
manager.add_command("shell", Shell(use_ipython=True, make_context=_make_context))
manager.add_command("runserver", server)
manager.add_command('db', MigrateCommand)


Exemple #9
0
import os

from flask import url_for
from flask.ext.migrate import Migrate, MigrateCommand
from flask.ext.script import Manager, Shell, Option
from flask.ext.security import script

dirname = os.path.dirname
sys.path.insert(0, dirname(dirname(os.path.abspath(__file__))))

import backend
import backend.blog.models
import backend.utils.wordpress_importer

migrate = Migrate()
migrate.init_app(backend.app, backend.db)

manager = Manager(backend.app)
manager.add_command('db', MigrateCommand)


class PromotedCreateUserCommand(script.CreateUserCommand):
    """Create a user"""

    option_list = (
        Option('-e', '--email', dest='email', default=None),
        Option('-p', '--password', dest='password', default=None),
        Option('-a', '--active', dest='active', default=''),
    )

    @script.commit
Exemple #10
0
import os

from flask import url_for
from flask.ext.migrate import Migrate, MigrateCommand
from flask.ext.script import Manager, Shell, Option
from flask.ext.security import script

dirname = os.path.dirname
sys.path.insert(0, dirname(dirname(os.path.abspath(__file__))))

import backend
import backend.blog.models
import backend.utils.wordpress_importer

migrate = Migrate()
migrate.init_app(backend.app, backend.db)

manager = Manager(backend.app)
manager.add_command('db', MigrateCommand)


class PromotedCreateUserCommand(script.CreateUserCommand):
    """Create a user"""

    option_list = (
        Option('-e', '--email', dest='email', default=None),
        Option('-p', '--password', dest='password', default=None),
        Option('-a', '--active', dest='active', default=''),
    )

    @script.commit