def test_method_command_decorator_with_pos_arg(self, capsys): manager = Manager(self.app) class SomeTest(object): def hello(self,name): print('hello ' + name) sometest = SomeTest() manager.command(sometest.hello) assert 'hello' in manager._commands code = run('manage.py hello joe', lambda: manager.run()) out, err = capsys.readouterr() assert 'hello joe' in out
def init_manager(manager): """Adds appropriate invite management commands to the Flask Script manager. These can be run from the command line. """ sub_manager = Manager( description='Commands for managing supplier invites', usage= 'Run "python application.py supplier_invites -?" to see subcommand list' ) sub_manager.command(send) sub_manager.command(list_candidates) sub_manager.command(list_unclaimed) manager.add_command('supplier_invites', sub_manager)
user.save() manager.add_command('shell', Shell(make_context=lambda: { 'app': app, 'db': db })) class DBClass(object): def __init__(self, cls): self.db = cls if __name__ == '__main__': app.extensions = app.extensions or {} app.extensions['sqlalchemy'] = DBClass(db) manager.add_command('clean', Clean()) manager.add_command('show_urls', ShowUrls()) manager.add_command('db', alembic_manager) get_templates = manager.command(get_templates) get_pyfiles = manager.command(get_pyfiles) #print os.environ.get('DATABASE_URL') #items = [(k, app.config[k]) for k in app.config.keys()] #for item in items: # print item with app.test_request_context(): User.metadata.bind = User.engine manager.run()
from webservices.env import env from webservices.rest import app, db from webservices.config import SQL_CONFIG, check_config from webservices.common.util import get_full_path import webservices.legal_docs as legal_docs from webservices.utils import post_to_slack manager = Manager(app) logger = logging.getLogger('manager') # The Flask app server should only be used for local testing, so we default to # using debug mode and auto-reload. To disable debug mode locally, pass the # --no-debug flag to `runserver`. manager.add_command('runserver', Server(use_debugger=True, use_reloader=True)) manager.command(legal_docs.delete_advisory_opinions_from_es) manager.command(legal_docs.delete_current_murs_from_es) manager.command(legal_docs.delete_murs_from_s3) manager.command(legal_docs.index_regulations) manager.command(legal_docs.index_statutes) manager.command(legal_docs.load_archived_murs) manager.command(legal_docs.load_advisory_opinions) manager.command(legal_docs.load_current_murs) manager.command(legal_docs.load_adrs) manager.command(legal_docs.load_admin_fines) manager.command(legal_docs.create_docs_index) manager.command(legal_docs.create_archived_murs_index) manager.command(legal_docs.create_staging_index) manager.command(legal_docs.restore_from_staging_index) manager.command(legal_docs.delete_all_indices) manager.command(legal_docs.move_archived_murs)
#!/usr/bin/env python # Load Flask and config from flask_migrate import MigrateCommand from flask_script import Manager from app import app, db, initdb # Start the server manager = Manager(app) manager.add_command('db', MigrateCommand) manager.command(initdb) if __name__ == '__main__': manager.run()
from webservices.rest import app, db from webservices.config import SQL_CONFIG, check_config from webservices.common.util import get_full_path import webservices.legal_docs as legal_docs from webservices.utils import post_to_slack from webservices.tasks import cache_request manager = Manager(app) logger = logging.getLogger('manager') # The Flask app server should only be used for local testing, so we default to # using debug mode and auto-reload. To disable debug mode locally, pass the # --no-debug flag to `runserver`. manager.add_command('runserver', Server(use_debugger=True, use_reloader=True)) manager.command(legal_docs.delete_advisory_opinions_from_es) manager.command(legal_docs.delete_murs_from_es) manager.command(legal_docs.delete_murs_from_s3) manager.command(legal_docs.index_regulations) manager.command(legal_docs.index_statutes) manager.command(legal_docs.load_archived_murs) manager.command(legal_docs.load_advisory_opinions) manager.command(legal_docs.load_current_murs) manager.command(legal_docs.create_docs_index) manager.command(legal_docs.create_archived_murs_index) manager.command(legal_docs.create_staging_index) manager.command(legal_docs.restore_from_staging_index) manager.command(legal_docs.delete_docs_index) manager.command(legal_docs.move_archived_murs) manager.command(legal_docs.initialize_current_legal_docs) manager.command(legal_docs.refresh_current_legal_docs_zero_downtime)
yield "main.data_json_book", {"book_number": i} @freezer.register_generator def travels_csv_book(): for i in range(1, 4): yield "main.travels_csv_book", {"book_number": i} @freezer.register_generator def cooccurences_json(): for i in range(1, 4): yield "main.cooccurences_json_book", {"book_number": i} return freezer if __name__ == "__main__": app = create_app() manager = Manager(app) freezer = get_freezer(app) freezer_manager = Manager(app) serve = freezer_manager.command(freezer.serve) run = freezer_manager.command(freezer.run) freeze = freezer_manager.command(freezer.freeze) manager.add_command("freeze", freezer_manager) manager.add_command("runserver", Server) manager.add_command("importdata", ImportData) manager.run()
from flask_migrate import Migrate, MigrateCommand from flask_script import Manager, Shell import os from app import create_app, db from app.utils.utils import createsuperuser app = create_app(os.getenv('FLASK_CONFIG') or 'default') migrate = Migrate(app=app, db=db) manager = Manager(app) def make_shell_context(): return dict(app=app, db=db) manager.add_command('shell', Shell(make_context=make_shell_context)) manager.add_command('db', MigrateCommand) manager.command(createsuperuser) if __name__ == '__main__': manager.run()
db.metadata = User.metadata db.metadata.bind = User.engine user = User.query.filter(User.email=='*****@*****.**') if user.count() > 0: user = User(username='******', email='*****@*****.**', password='******') user.save() manager.add_command('shell', Shell(make_context=lambda:{'app': app, 'db': db})) class DBClass(object): def __init__(self,cls): self.db = cls if __name__ == '__main__': app.extensions = app.extensions or {} app.extensions['sqlalchemy'] = DBClass(db) manager.add_command('clean',Clean()) manager.add_command('show_urls',ShowUrls()) manager.add_command('db',alembic_manager) get_templates = manager.command(get_templates) get_pyfiles = manager.command(get_pyfiles) #print os.environ.get('DATABASE_URL') #items = [(k, app.config[k]) for k in app.config.keys()] #for item in items: # print item with app.test_request_context(): User.metadata.bind = User.engine manager.run()
from tornado.httpserver import HTTPServer from tornado.ioloop import IOLoop http_server = HTTPServer(WSGIContainer(app)) http_server.listen(app.config['PORT'], address=app.config['HOST']) IOLoop.instance().start() @manager.command def init(): logging.basicConfig(level=logging.INFO) alembic.upgrade() setup_default_permissions() if app.config['DEBUG']: logging.basicConfig(level=logging.DEBUG) @manager.command def reset(): print('resetting the database') db.drop_all() alembic.upgrade() setup_default_permissions() print('reset done') manager.command(update_ldap) if __name__ == "__main__": manager.run()
from webservices.rest import app, db from webservices.config import SQL_CONFIG, check_config from webservices.common.util import get_full_path from webservices.tasks.utils import get_bucket, get_object import webservices.legal_docs as legal_docs manager = Manager(app) logger = logging.getLogger('manager') logging.basicConfig(level=logging.INFO) # The Flask app server should only be used for local testing, so we default to # using debug mode and auto-reload. To disable debug mode locally, pass the # --no-debug flag to `runserver`. manager.add_command('runserver', Server(use_debugger=True, use_reloader=True)) manager.command(legal_docs.delete_advisory_opinions_from_s3) manager.command(legal_docs.delete_murs_from_es) manager.command(legal_docs.delete_murs_from_s3) manager.command(legal_docs.index_advisory_opinions) manager.command(legal_docs.index_regulations) manager.command(legal_docs.index_statutes) manager.command(legal_docs.load_advisory_opinions_into_s3) manager.command(legal_docs.load_archived_murs) manager.command(legal_docs.load_current_murs) manager.command(legal_docs.remap_archived_murs_citations) manager.command(legal_docs.remove_legal_docs) def check_itemized_queues(schedule): """Checks to see if the queues associated with an itemized schedule have been successfully cleared out and sends the information to the logs.
from webservices.load_legal_docs import (remove_legal_docs, index_statutes, index_regulations, index_advisory_opinions, load_advisory_opinions_into_s3, delete_advisory_opinions_from_s3) manager = Manager(app) logger = logging.getLogger('manager') logging.basicConfig(level=logging.INFO) # The Flask app server should only be used for local testing, so we default to # using debug mode and auto-reload. To disable debug mode locally, pass the # --no-debug flag to `runserver`. manager.add_command('runserver', Server(use_debugger=True, use_reloader=True)) manager.command(remove_legal_docs) manager.command(index_statutes) manager.command(index_regulations) manager.command(index_advisory_opinions) manager.command(load_advisory_opinions_into_s3) manager.command(delete_advisory_opinions_from_s3) def check_itemized_queues(schedule): """Checks to see if the queues associated with an itemized schedule have been successfully cleared out and sends the information to the logs. """ remaining_new_queue = db.engine.execute( 'select count(*) from ofec_sched_{schedule}_queue_new'.format( schedule=schedule)).scalar()
from webservices.env import env from webservices.rest import app, db from webservices.config import SQL_CONFIG, check_config from webservices.common.util import get_full_path import webservices.legal_docs as legal_docs from webservices.utils import post_to_slack manager = Manager(app) logger = logging.getLogger('manager') # The Flask app server should only be used for local testing, so we default to # using debug mode and auto-reload. To disable debug mode locally, pass the # --no-debug flag to `runserver`. manager.add_command('runserver', Server(use_debugger=True, use_reloader=True)) manager.command(legal_docs.delete_advisory_opinions_from_es) manager.command(legal_docs.delete_murs_from_es) manager.command(legal_docs.delete_murs_from_s3) manager.command(legal_docs.index_regulations) manager.command(legal_docs.index_statutes) manager.command(legal_docs.load_archived_murs) manager.command(legal_docs.load_advisory_opinions) manager.command(legal_docs.load_current_murs) manager.command(legal_docs.create_docs_index) manager.command(legal_docs.create_archived_murs_index) manager.command(legal_docs.create_staging_index) manager.command(legal_docs.restore_from_staging_index) manager.command(legal_docs.delete_docs_index) manager.command(legal_docs.move_archived_murs) manager.command(legal_docs.initialize_current_legal_docs) manager.command(legal_docs.refresh_current_legal_docs_zero_downtime)
import os from flask_script import Manager, Server from .app import app, build, initial_data_structure, __version__ manager = Manager(app) manager.add_command("runserver", Server(host="0.0.0.0", port=5000)) build = manager.command(build) initial_data_structure = manager.command(initial_data_structure) @manager.command def version(): print("Workbench %s" % __version__) if __name__ == '__main__': print("Static is server from %s" % os.path.join(os.getcwd(), 'static')) manager.run()