示例#1
0
 def setUpClass(cls):
     """
     Make sure correct database is being used and if so, that is clean
     """
     super(BaseTestCase, cls).setUpClass()
     cls.app = create_app("config.TestConfig")
     cls.app.logger.info("Using \"{}\" database".format(cls.app.config.get('MONGODB_DB')))
# -*- coding: utf-8 -*-
#
from project import create_app, create_celery

app = create_app(config='../local.cfg')
celery = create_celery(app)
celery.start()
示例#3
0
 def create_app(self):
     test_app = create_app('test')
     return test_app
示例#4
0
 def create_app(self):
     app = create_app()
     app.config.from_object('project.config.TestingConfig')
     return app
示例#5
0
#! /usr/bin/env python

import os

from flask_script import Manager

from project import create_app, db, bcrypt
from project.models.user import User

app = create_app(os.getenv('PROJECT_CONFIG', 'default'))
manager = Manager(app)

@manager.shell
def make_shell_context():
    return dict(app=app, db=db)


@manager.command
def create_db():
    '''Creates the db tables.'''
    db.create_all()
    db.session.add(User('root', bcrypt.generate_password_hash('root'), None))
    db.session.commit()

@manager.command
def drop_db():
    """Drops the db tables."""
    db.drop_all()
    
if __name__ == '__main__':
    manager.run()
示例#6
0
import os
from flask import Flask
from flask.ext.script import Manager
from flask.ext.migrate import Migrate, MigrateCommand
from project import create_app, db

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

app = create_app('default')
manager = Manager(app)
migrate = Migrate(app, db)
manager.add_command('db', MigrateCommand)

if __name__ == '__main__':
	manager.run()
示例#7
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os, shutil
from datetime import datetime
from project import create_app
from flask.ext.script import Manager, Shell, prompt_bool
from flask.ext.migrate import Migrate, MigrateCommand

from project.apps.account.models import User

app = create_app(os.getenv('FLASK_CONFIG') or 'default')
db = app.config['db']
manager = Manager(app)
migrate = Migrate(app, db)


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)

# 打印url映射表
print(app.url_map)

if __name__ == '__main__':
    manager.run()
示例#8
0
文件: deploy.py 项目: PyIran/website
from project import create_app
from project.config import DeploymentConfig


application = create_app(DeploymentConfig)
示例#9
0
import unittest
from flask.cli import FlaskGroup

from project import create_app, db
from project.api.models import User

app = create_app()
cli = FlaskGroup(create_app=create_app)


@cli.command()
def recreate_db():
    db.drop_all()
    db.create_all()
    db.session.commit()


@cli.command()
def test():
    """ Runs the tests without code coverage"""
    tests = unittest.TestLoader().discover('project/tests', pattern='test*.py')
    result = unittest.TextTestRunner(verbosity=2).run(tests)
    if result.wasSuccessful():
        return 0
    return 1


@cli.command()
def seed_db():
    """Seeds the database."""
    db.session.add(User(username='******', email='*****@*****.**'))
示例#10
0
# -*- coding: utf-8 -*-

# ------------------------------------
# Imports
# ------------------------------------

import logging

import project

logging.debug("Iniciando servidor Flask")

app = project.create_app()

# ------------------------------------
# 'Main'
# ------------------------------------
if __name__ == "__main__":
    app.run(host="0.0.0.0", port=5000)
示例#11
0
def test_app():
    app = create_app()
    app.config.from_object("project.config.TestingConfig")
    with app.app_context():
        yield app  # testing happens here
示例#12
0
 def create_app(self):
     app = create_app(testing=True)
     return app
示例#13
0
import click
import random

from project import create_app, db
from flask.cli import with_appcontext

app = create_app('flask.cfg')


@app.cli.command('init-db')
@with_appcontext
def init_db_command():

    tags_series = 400
    graphics = 1000
    max_tags_per_graphic = 1000

    def fill_db(prod_db):
        random.seed(42)
        tag_names = [
            '{0}_{1}'.format(name, i) for i in range(tags_series)
            for name in ('tesla', 'mask', 'ev')
        ]
        db_tags = []
        for element in tag_names:
            tag = Tag(element)
            db_tags.append(tag)
            prod_db.session.add(tag)
        for i in range(graphics):
            graph = Graph('G1{:05d}'.format(i))
            graph.tags.extend(
示例#14
0
 def setUp(self):
     self.test_app = create_app()
     self.test_app.config.from_object("project.config.TestingConfig")
示例#15
0
import os
from flask_script import Manager  # class for handling a set of commands
from flask_migrate import Migrate, MigrateCommand
from project import db, create_app
from project.models import Booking
import psycopg2

ENVIRONMENT = os.environ.get('ENVIRONMENT')

app = create_app(ENVIRONMENT)
migrate = Migrate(app, db)
manager = Manager(app)

manager.add_command('db', MigrateCommand)

if __name__ == '__main__':
    manager.run()
示例#16
0
文件: conftest.py 项目: Pektech/dread
def app():
    app = create_app()
    return app
示例#17
0
"""Basic app file."""

from project import create_app


if __name__ == "__main__":
    app = create_app('config.Test')
    app.run()
示例#18
0
文件: manage.py 项目: tpebcp/2nd
from flask.cli import FlaskGroup

from project import create_app, db  # new
from project.api.models import User  # new

# coverge here to help

COV = coverage.coverage(
    branch=True, include="project/*", omit=["project/tests/*", "project/config.py"]
)
COV.start()

# to read __init__.py under folder project so it can include variable app and db

app = create_app()  # new
cli = FlaskGroup(create_app=create_app)  # new


# new
# This registers a new command, recreate_db, to the CLI
# so that we can run it from the command line, which we'll use shortly to apply the model to the database
@cli.command("recreate_db")
def recreate_db():
    db.drop_all()
    db.create_all()
    db.session.commit()


@cli.command()
def test():
示例#19
0
 def create_app(self):
     app = create_app('config.Test')
     return app
示例#20
0
#!venv/bin/python
import os
import warnings
warnings.filterwarnings("ignore")

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

try:
    from project import config_mysql
    os.environ['DATABASE_URL'] = 'mysql://%s:%s@localhost/%s' % (
        config_mysql.username, config_mysql.password, config_mysql.db)

except ImportError:
    os.environ['DATABASE_URL'] = 'sqlite:///' \
        + os.path.join(basedir, 'project/app.db')

from flup.server.fcgi import WSGIServer

from project import create_app, db
from flask_script import Manager, Shell
from flask_migrate import Migrate, MigrateCommand

app = create_app('production')
manager = Manager(app)
migrate = Migrate(app, db)

if __name__ == '__main__':
    WSGIServer(app).run()
示例#21
0
#!/usr/bin/env python
# find . -name "*.pyc" -exec rm -rf {} \;
# -*- coding: utf-8 -*-

from project import create_app
from project.config import DevelopmentConfig

application = create_app(DevelopmentConfig)

if __name__ == '__main__':
    application.run()
示例#22
0
# !/usr/bin/python
# -*- coding: utf-8 -*-
from flask_script import Manager
from flask import render_template
from project import create_app

# in case we run the test command choose the "TestConfig"
import sys
arg_dict = dict((i, v) for i, v in enumerate(sys.argv))
config = "config.TestConfig" if arg_dict.get(1, None) == "test" else None
app = create_app(config)
manager = Manager(app)


@app.errorhandler(404)
def page_not_found(e):
    return render_template('404.html'), 404


if __name__ == '__main__':
    import project.commands as cmd
    manager.add_command("worker", cmd.WorkerCommand())
    manager.add_command("test", cmd.TestCommand())
    manager.add_command("routes", cmd.ListRoutesCommand())
    manager.add_command("create-user", cmd.CreateUserCommand())
    manager.add_command("delete-user", cmd.DeleteUserCommand())
    manager.add_command("create-db", cmd.CreateDBCommand())
    manager.run()


__version__ = '0.2.0'
示例#23
0
from project import create_app

app = create_app()

if __name__ == "__main__":
    with app.app_context():
        app.run()
示例#24
0
 def create_app(self):
     test_app = create_app('test')
     test_app.config['TESTING'] = True
     return test_app
from project import create_app
from flask_script import Manager

config_name = 'development'
app = create_app(config_name)

manager = Manager(app)

if __name__ == '__main__':
    manager.run()
示例#26
0
def test_app():
    app = create_app()
    app.config.from_object('project.config.TestingConfig')
    with app.app_context():
        yield app  # this is where the testing happens