Exemplo n.º 1
0
def main(argv):
    app = create_app()
    mode = ""
    helpoutput = """
USAGE:
-d              Use in development server (DON'T USE IT IN PRODUCTION SERVER)
-p              Create database tailored to production server
"""
    error_message = "ERROR: use -h to see help"
    try:
        opts, args = getopt.getopt(argv, "hdp", ["dev", "prod"])
    except getopt.GetoptError:
        print(error_message)
        sys.exit(2)
    for opt, arg in opts:
        if opt == '-h':
            print(helpoutput)
            sys.exit()
        elif opt in ("-d", "--dev"):
            mode = "dev"
        elif opt in ("-p", "--prod"):
            mode = "prod"

    if (mode == "dev"):
        drop_everything(app)
        create_database(app)
        create_mockData(app, create_admin=True)
    elif (mode == "prod"):
        drop_everything(app)
        create_database(app)
        create_mockData(app, create_admin=False)
    else:
        print(error_message)
Exemplo n.º 2
0
 def setUpClass(cls):
     app = create_app()
     ctx = app.app_context()
     ctx.push()
     db.drop_all()
     db.create_all()
     create_users()
     create_products()
Exemplo n.º 3
0
def app():
    app = create_app()
    app.config.from_object(TestConfig)
    with app.app_context():
        db.create_all()
        yield app
        db.session.remove()  # looks like db.session.close() would work as well
        db.drop_all()
Exemplo n.º 4
0
def main():
    app = create_app()
    ctx = app.app_context()
    ctx.push()
    db.drop_all()
    db.create_all()
    create_superuser()
    create_products()
Exemplo n.º 5
0
#!/usr/bin/env python
import os
from WebApp import create_app, db
from WebApp.models import User
from flask_script import Manager, Shell
from flask_migrate import Migrate, MigrateCommand

app = create_app(os.getenv('FLASK_CONFIG') or 'default')

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


def make_shell_context():
    return dict(app=app, db=db, User=User, Role=Role)


manager.add_command("shell", Shell(make_context=make_shell_context))
manager.add_command('db', MigrateCommand)

if __name__ == '__main__':
    manager.run()
Exemplo n.º 6
0
from WebApp import create_app
from WebApp.prepare import prepare

app = create_app()
try:
    from experiment import app_modify
    app_modify(app)
except ImportError:
    print("WARNING: COULD NOT LOAD EXPERIMENT.PY")

prepare(app)
app.run(debug=True)
Exemplo n.º 7
0
from WebApp import create_app, db, bcrypt
from WebApp.models import User, Link, Role, access
import json

db.create_all(app=create_app())
app = create_app()

# import JSON file  #
with open('site.json', 'r') as json_file:
    json_data = json_file.read()
    print(json_data)
    data = json.loads(json_data)
    #print(data)
    #for d in data['link1']:
    #    print(d.group)

# parse JSON file #

# Sort Json content into table groups #

# remove table attribute from each object #

ctx = app.app_context()
ctx.push()

# for loop through each table group #
# for each object in group create based on that table's lable#

#in try except block#

ctx.pop()
Exemplo n.º 8
0
def app():
    app = create_app({"TESTING": True})

    yield app