import sys import subprocess from flask.ext.script import Manager, Shell, Server from flask.ext.migrate import MigrateCommand from {{cookiecutter.app_name}}.app import create_app from {{cookiecutter.app_name}}.user.models import User from {{cookiecutter.app_name}}.settings import DevConfig, ProdConfig from {{cookiecutter.app_name}}.database import db if os.environ.get("{{cookiecutter.app_name | upper}}_ENV") == 'prod': app = create_app(ProdConfig) else: app = create_app(DevConfig) manager = Manager(app) TEST_CMD = "py.test tests" def _make_context(): """Return context dict for a shell session so you can access app, db, and the User model by default. """ return {'app': app, 'db': db, 'User': User} @manager.command def test(): """Run the tests.""" import pytest exit_code = pytest.main(['tests', '--verbose']) return exit_code
def create_app(config=None): app = Flask(__name__) app.debug = False print("CONFIG", config) app.config.from_envvar('APP_CONFIG', silent=True) @app.route("/") def index(): # deliberate error, test debug working assert False, "oops" return app manager = Manager(create_app) @manager.command def dumpconfig(): "Dumps config" pprint.pprint(current_app.config) @manager.command def output(name): "print something" print(name) print(type(name))
#!/usr/bin/env python # -*- coding: utf-8 -*- """ manage ~~~~~~ """ import subprocess from flask.ext.script import Shell, Manager, prompt_bool from flask.ext.script.commands import Clean from flask.ext.xxl import flaskxxl manager = Manager(flaskxxl) from flask.ext.xxl.mr_bob import manager as mrbob_manager if __name__ == '__main__': manager.add_command('mrbob', mrbob_manager) manager.add_command('clean', Clean()) manager.run()
import random import math from flask.ext.script import Manager from app import app, db from models import DocumentType, MetadataProperty, Document FixturesCommand = Manager(usage='Perform database fixture insertion') @FixturesCommand.command def init(): print '\nExecuting the fixture init command...\n' all_document_types = add_document_types() all_metadata_properties = add_metadata_properties() link_document_types_to_properties(all_document_types, all_metadata_properties) all_documents = add_documents(all_document_types, all_metadata_properties) print '\n' def add_document_types(): print '\tAdding the DocumentTypes:' all_document_types = DocumentType.query.all() if len(all_document_types) is 0: # add document types doc_type1 = DocumentType('protocol', 'Protocol') doc_type2 = DocumentType('consent', 'Consent') doc_type3 = DocumentType('contract', 'Contract') db.session.add(doc_type1) db.session.add(doc_type2) db.session.add(doc_type3)
from flask.ext.script import Manager, Server from grapher import Grapher from vertex import settings if __name__ == "__main__": grapher = Grapher(__name__) manager = Manager(grapher.app) manager.add_command('runserver', Server(port=80)) manager.run()