예제 #1
1
def main(create_app_func=None):
    
    if not create_app_func:
        from widukind_web.wsgi import create_app
        create_app_func = create_app
    
    class ServerWithGevent(Server):
        help = description = 'Runs the Flask development server with Gevent WSGI Server'
    
        def __call__(self, app, host, port, use_debugger, use_reloader,
                   threaded, processes, passthrough_errors):

            if use_debugger:
                app = DebuggedApplication(app, evalex=True)
    
            server = WSGIServer((host, port), app)
            try:
                print('Listening on http://%s:%s' % (host, port))
                server.serve_forever()
            except KeyboardInterrupt:
                pass
    
    env_config = config_from_env('WIDUKIND_SETTINGS', 'widukind_web.settings.Prod')
    
    manager = Manager(create_app_func, 
                      with_default_commands=False)
    
    #TODO: option de config app pour désactiver run counter
    
    manager.add_option('-c', '--config',
                       dest="config",
                       default=env_config)

    manager.add_command("shell", Shell())

    if HAS_GEVENT:
        manager.add_command("server", ServerWithGevent(
                        host = '0.0.0.0',
                        port=8081)
        )
    else:
        manager.add_command("server", Server(
                        host = '0.0.0.0',
                        port=8081)
        )

    manager.add_command("config", ShowConfigCommand())
    manager.add_command("urls", ShowUrlsCommand())
    
    manager.add_command("assets", ManageAssets())
    
    manager.run()
예제 #2
0
def main():
    """Main function of the script, setting up the shell manager."""
    # Setup Flask-script command manager and register commands.
    shell_manager = Manager(create_app)
    shell_manager.add_command('add_user', AddUser())
    shell_manager.add_command('make_admin', MakeUserAdmin())
    shell_manager.add_command('list_users', ListUsers())
    shell_manager.add_command('add_group', AddGroup())
    shell_manager.add_command('list_groups', ListGroups)
    shell_manager.add_command('manage_group', GroupManager())
    shell_manager.add_command('add_index', AddSearchIndex())
    shell_manager.add_command('db', MigrateCommand)
    shell_manager.add_command('drop_db', DropDataBaseTables())
    shell_manager.add_command('list_sketches', ListSketches())
    shell_manager.add_command('purge', PurgeTimeline())
    shell_manager.add_command('search_template', SearchTemplateManager())
    shell_manager.add_command('import', ImportTimeline())
    shell_manager.add_command('version', GetVersion())
    shell_manager.add_command('runserver', Server(host='127.0.0.1', port=5000))
    shell_manager.add_option('-c',
                             '--config',
                             dest='config',
                             default='/etc/timesketch/timesketch.conf',
                             required=False)
    shell_manager.run()
예제 #3
0
def main():
    manager = Manager(create_app)

    manager.add_option('-c', '--config', dest='config', required=True)

    manager.add_command('db', MigrateCommand)

    manager.run()
예제 #4
0
def main():
    manager = Manager(create_app)
    manager.add_option('-c',
                       '--config',
                       dest='config_name',
                       required=False,
                       default='config.prod')
    manager.add_command('shell', Shell())
    manager.run()
예제 #5
0
def main(create_app_func=None):
    
    """
    TODO: commands pour créer fixtures de chaque mode pour démo
    """
    if not create_app_func:
        from mongo_mail_web.wsgi import create_app
        create_app_func = create_app
    
    class ServerWithGevent(Server):
        help = description = 'Runs the Flask development server with WSGI SocketIO Server'
    
        def __call__(self, app, host, port, use_debugger, use_reloader,
                   threaded, processes, passthrough_errors):
            #console_path='/console'
            if use_debugger:
                app = DebuggedApplication(app, evalex=True)
    
            """
            TODO: 
            from policyng_web.clients import tasks
            tasks.start_all(app)
            """
            server = WSGIServer((host, port), app)
            try:
                print 'Listening on http://%s:%s' % (host, port)
                server.serve_forever()
            except KeyboardInterrupt:
                pass
    
    env_config = config_from_env('MMW_SETTINGS', 'mongo_mail_web.settings.Prod')
    
    manager = Manager(create_app_func, with_default_commands=False)
    manager.add_option('-c', '--config',
                       dest="config",
                       default=env_config)

    manager.add_command("shell", Shell())

    manager.add_command("server", ServerWithGevent(
                    host = '0.0.0.0',
                    port=8081)
    )

    manager.add_command("config", ShowConfigCommand())
    manager.add_command("urls", ShowUrlsCommand())
    manager.add_command("reset-db", ResetCommand())
    manager.add_command("reset-metrics", ResetMetrics())
    
    manager.add_command('users', ShowUsersCommand())
    manager.add_command('create-superadmin', CreateSuperAdminCommand())
    
    manager.run()
예제 #6
0
def main(create_app_func=None):
    
    if not create_app_func:
        from mongrey.web.wsgi import create_app
        create_app_func = create_app
    
    class ServerWithGevent(Server):
        help = description = 'Runs the Flask server with Gevent WSGI'
    
        def __call__(self, app, host=None, port=None, use_debugger=None, use_reloader=None,
                   threaded=False, processes=1, passthrough_errors=False):
            
            config = app.config
            logger = app.logger
            
            if use_debugger:
                app = DebuggedApplication(app, evalex=True)
    
            host = config.get('WEB_HOST', host)
            port = config.get('WEB_PORT', port)
            security_by_host = config.get('SECURITY_BY_HOST', False)
            allow_hosts = config.get('ALLOW_HOSTS', [])
    
            server = SecureWSGIServer((host, port), application=app,
                                      security_by_host=security_by_host,
                                      allow_hosts=allow_hosts,
                                      #log=GeventAccessLogger(logger)
                                      )
            try:
                logger.info('Listening on http://%s:%s' % (host, port))
                server.serve_forever()
            except KeyboardInterrupt:
                pass
    
    env_config = config_from_env('MONGREY_SETTINGS', 'mongrey.web.settings.Prod')
    
    manager = Manager(create_app_func, with_default_commands=False)
    manager.add_option('-c', '--config',
                       dest="config",
                       default=env_config)

    manager.add_command("shell", Shell())

    manager.add_command("server", ServerWithGevent())

    manager.add_command("config", ShowConfigCommand())
    manager.add_command("urls", ShowUrlsCommand())
    
    manager.add_command("default-user", CreateDefaultUserCommand())    
    
    manager.add_command("import-whitelist", ImportWhiteList())
    
    manager.run()
예제 #7
0
def main():
    # create application
    manager = Manager(inc.create_app)
    # add config, default by dev/dev.py
    manager.add_option('-c', '--config', dest='config', required=False, default='../config/config.py')
    # show the application's url routes
    manager.add_command("urls", ShowUrls())
    # clean .pyc .pyo
    manager.add_command("clean", Clean())
    manager.add_command("init", InitApp())

    try:
        manager.run()
    except KeyboardInterrupt:
        print('KeyboardInterrupt cause quit')
예제 #8
0
파일: tests.py 프로젝트: imfht/flaskapps
    def test_submanager_separate_options(self, capsys):

        sub_manager = Manager(AppForTesting(verbose=True), with_default_commands=False)
        sub_manager.add_command('opt', CommandWithOptionalArg())
        sub_manager.add_option('-n', '--name', dest='name_sub', required=False)

        manager = Manager(AppForTesting(verbose=True), with_default_commands=False)
        manager.add_command('sub_manager', sub_manager)
        manager.add_option('-n', '--name', dest='name_main', required=False)

        code = run('manage.py -n MyMainName sub_manager -n MySubName opt -n MyName', manager.run)
        out, err = capsys.readouterr()
        assert code == 0
        assert 'APP name_main=MyMainName' in out
        assert 'APP name_sub=MySubName' in out
        assert 'OK name=MyName' in out
예제 #9
0
def main(create_app_func=None):
    """
    TODO: commands pour créer fixtures de chaque mode pour démo
    """
    if not create_app_func:
        from mongo_mail_web.wsgi import create_app
        create_app_func = create_app

    class ServerWithGevent(Server):
        help = description = 'Runs the Flask development server with WSGI SocketIO Server'

        def __call__(self, app, host, port, use_debugger, use_reloader,
                     threaded, processes, passthrough_errors):
            #console_path='/console'
            if use_debugger:
                app = DebuggedApplication(app, evalex=True)
            """
            TODO: 
            from policyng_web.clients import tasks
            tasks.start_all(app)
            """
            server = WSGIServer((host, port), app)
            try:
                print 'Listening on http://%s:%s' % (host, port)
                server.serve_forever()
            except KeyboardInterrupt:
                pass

    env_config = config_from_env('MMW_SETTINGS',
                                 'mongo_mail_web.settings.Prod')

    manager = Manager(create_app_func, with_default_commands=False)
    manager.add_option('-c', '--config', dest="config", default=env_config)

    manager.add_command("shell", Shell())

    manager.add_command("server", ServerWithGevent(host='0.0.0.0', port=8081))

    manager.add_command("config", ShowConfigCommand())
    manager.add_command("urls", ShowUrlsCommand())
    manager.add_command("reset-db", ResetCommand())
    manager.add_command("reset-metrics", ResetMetrics())

    manager.add_command('users', ShowUsersCommand())
    manager.add_command('create-superadmin', CreateSuperAdminCommand())

    manager.run()
예제 #10
0
파일: tests.py 프로젝트: imfht/flaskapps
    def test_global_option_provided_before_and_after_command(self, capsys):

        manager = Manager(self.app)
        manager.add_option('-c', '--config', dest='config_name', required=False, default='Development')
        manager.add_command('simple', SimpleCommand())

        assert isinstance(manager._commands['simple'], SimpleCommand)

        code = run('manage.py -c Development simple', manager.run)
        out, err = capsys.readouterr()
        assert code == 0
        assert 'OK' in out

        code = run('manage.py simple -c Development', manager.run)
        out, err = capsys.readouterr()
        assert code == 2
        assert 'OK' not in out
예제 #11
0
파일: tests.py 프로젝트: imfht/flaskapps
    def test_global_option_value(self, capsys):

        def create_app(config_name='Empty'):
            print(config_name)
            return self.app

        manager = Manager(create_app)
        manager.add_option('-c', '--config', dest='config_name', required=False, default='Development')
        manager.add_command('simple', SimpleCommand())

        assert isinstance(manager._commands['simple'], SimpleCommand)

        code = run('manage.py simple', manager.run)
        out, err = capsys.readouterr()
        assert code == 0
        assert 'Empty' not in out  # config_name is overwritten by default option value
        assert 'Development' in out
        assert 'OK' in out
예제 #12
0
파일: tests.py 프로젝트: imfht/flaskapps
    def test_submanager_has_options(self, capsys):

        sub_manager = Manager()
        sub_manager.add_command('simple', SimpleCommand())

        manager = Manager(self.app)
        manager.add_command('sub_manager', sub_manager)
        manager.add_option('-c', '--config', dest='config', required=False)

        code = run('manage.py sub_manager simple', manager.run)
        out, err = capsys.readouterr()
        assert code == 0
        assert 'OK' in out

        code = run('manage.py -c Development sub_manager simple', manager.run)
        out, err = capsys.readouterr()
        assert code == 0
        assert 'OK' in out
예제 #13
0
def main():
    # Setup Flask-script command manager and register commands.
    shell_manager = Manager(create_app)
    shell_manager.add_command('add_user', AddUser())
    shell_manager.add_command('add_group', AddGroup())
    shell_manager.add_command('manage_group', GroupManager())
    shell_manager.add_command('add_index', AddSearchIndex())
    shell_manager.add_command('db', MigrateCommand)
    shell_manager.add_command('drop_db', DropDataBaseTables())
    shell_manager.add_command('purge', PurgeTimeline())
    shell_manager.add_command('search_template', SearchTemplateManager())
    shell_manager.add_command('import', ImportTimeline())
    shell_manager.add_command('runserver', Server(host='127.0.0.1', port=5000))
    shell_manager.add_option('-c',
                             '--config',
                             dest='config',
                             default='/etc/timesketch.conf',
                             required=False)
    shell_manager.run()
예제 #14
0
def main():
    # Setup Flask-script command manager and register commands.
    shell_manager = Manager(create_app)
    shell_manager.add_command('add_user', AddUser())
    shell_manager.add_command('add_group', AddGroup())
    shell_manager.add_command('manage_group', GroupManager())
    shell_manager.add_command('add_index', AddSearchIndex())
    shell_manager.add_command('db', MigrateCommand)
    shell_manager.add_command('drop_db', DropDataBaseTables())
    shell_manager.add_command('purge', PurgeTimeline())
    shell_manager.add_command('search_template', SearchTemplateManager())
    shell_manager.add_command('import', ImportTimeline())
    shell_manager.add_command('runserver',
                              Server(host='127.0.0.1', port=5000))
    shell_manager.add_option(
        '-c',
        '--config',
        dest='config',
        default='/etc/timesketch.conf',
        required=False)
    shell_manager.run()
예제 #15
0
def main(default_command='moin', wiki_config=None):
    """
    console_script entry point
    """
    from MoinMoin.app import create_app
    from flask_script import Manager, Server

    manager = Manager(create_app)
    manager.add_option('-c',
                       '--config',
                       dest='config',
                       required=False,
                       default=wiki_config)
    manager.add_option('-i',
                       '--index-create',
                       action='store_true',
                       dest='create_index',
                       required=False,
                       default=False)
    manager.add_option('-s',
                       '--storage-create',
                       action='store_true',
                       dest='create_storage',
                       required=False,
                       default=False)
    manager.add_command("moin", Server(host='127.0.0.1', port=8080))

    from MoinMoin.script.maint import index
    manager.add_command("index-create", index.IndexCreate())
    manager.add_command("index-build", index.IndexBuild())
    manager.add_command("index-update", index.IndexUpdate())
    manager.add_command("index-destroy", index.IndexDestroy())
    manager.add_command("index-move", index.IndexMove())
    manager.add_command("index-optimize", index.IndexOptimize())
    manager.add_command("index-dump", index.IndexDump())
    from MoinMoin.script.maint import serialization
    manager.add_command("save", serialization.Serialize())
    manager.add_command("load", serialization.Deserialize())
    from MoinMoin.script.maint.dump_html import Dump
    manager.add_command("dump-html", Dump())
    from MoinMoin.script.account.create import Create_User
    manager.add_command("account-create", Create_User())
    from MoinMoin.script.account.disable import Disable_User
    manager.add_command("account-disable", Disable_User())
    from MoinMoin.script.account.resetpw import Set_Password
    manager.add_command("account-password", Set_Password())
    from MoinMoin.script.maint.reduce_revisions import Reduce_Revisions
    manager.add_command("maint-reduce-revisions", Reduce_Revisions())
    from MoinMoin.script.maint.set_meta import Set_Meta
    manager.add_command("maint-set-meta", Set_Meta())
    from MoinMoin.script.maint import modify_item
    manager.add_command("item-get", modify_item.GetItem())
    manager.add_command("item-put", modify_item.PutItem())
    from MoinMoin.script.migration.moin19.import19 import ImportMoin19
    manager.add_command("import19", ImportMoin19())

    from MoinMoin.script.maint.moinshell import MoinShell
    manager.add_command("shell", MoinShell())

    return manager.run(default_command=default_command)
예제 #16
0
from lemur import create_app

# Needed to be imported so that SQLAlchemy create_all can find our models
from lemur.users.models import User  # noqa
from lemur.roles.models import Role  # noqa
from lemur.authorities.models import Authority  # noqa
from lemur.certificates.models import Certificate  # noqa
from lemur.destinations.models import Destination  # noqa
from lemur.domains.models import Domain  # noqa
from lemur.notifications.models import Notification  # noqa
from lemur.sources.models import Source  # noqa
from lemur.logs.models import Log  # noqa

manager = Manager(create_app)
manager.add_option('-c', '--config', dest='config')

migrate = Migrate(create_app)

REQUIRED_VARIABLES = [
    'LEMUR_SECURITY_TEAM_EMAIL', 'LEMUR_DEFAULT_ORGANIZATIONAL_UNIT',
    'LEMUR_DEFAULT_ORGANIZATION', 'LEMUR_DEFAULT_LOCATION',
    'LEMUR_DEFAULT_COUNTRY', 'LEMUR_DEFAULT_STATE', 'SQLALCHEMY_DATABASE_URI'
]

KEY_LENGTH = 40
DEFAULT_CONFIG_PATH = '~/.lemur/lemur.conf.py'
DEFAULT_SETTINGS = 'lemur.conf.server'
SETTINGS_ENVVAR = 'LEMUR_CONF'

CONFIG_TEMPLATE = """
예제 #17
0
파일: manage.py 프로젝트: dfm/osrc
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from flask_script import Manager

from osrc import create_app
from osrc.manage import (
    CreateTablesCommand, DropTablesCommand, UpdateCommand,
)

if __name__ == "__main__":
    manager = Manager(create_app)
    manager.add_option("-f", "--filename", dest="config_filename",
                       required=False)

    manager.add_command("create", CreateTablesCommand())
    manager.add_command("drop", DropTablesCommand())
    manager.add_command("update", UpdateCommand())

    manager.run()
예제 #18
0
#!/usr/bin/env python
# encoding: utf-8
import sys
import subprocess

from flask_script import Manager
from flask_script.commands import ShowUrls
from flask_migrate import MigrateCommand

from application import create_app
from application.extensions import db
from utils.commands import GEventServer, ProfileServer


manager = Manager(create_app)
manager.add_option('-c', '--config', dest='mode', required=False)

manager.add_command("showurls", ShowUrls())
manager.add_command("gevent", GEventServer())
manager.add_command("profile", ProfileServer())
manager.add_command('db', MigrateCommand)


@manager.option('-c', '--config', help='enviroment config')
def simple_run(config):
    app = create_app(config)
    app.run(host="0.0.0.0", port=9192, debug=True)


@manager.command
def lint():
예제 #19
0
import unittest
from flask_script import Manager, Server
from flask_migrate import MigrateCommand
from app import create_app
from extensions import db

manager = Manager(create_app)

## COMMANDS & OPTIONS ########################################################
"""This is used to switch between Development, Testing and Production mode"""
manager.add_option(
    '-m',
    '--mode',
    dest='mode',
    required=False,
)

manager.add_command('db', MigrateCommand)
manager.add_command('runserver', Server(host="0.0.0.0", port=8000))


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

예제 #20
0
    app.register_blueprint(preseed_module, url_prefix='/preseed')
    app.register_blueprint(tftp_module, url_prefix='/tftp')
    app.register_blueprint(dhcp_module, url_prefix='/dhcp')
    app.register_blueprint(api_v1_module, url_prefix='/api/v1')

    @app.route('/')
    def index():
        return redirect(url_for('admin.index'))

    return app


manager = Manager(create_app)
manager.add_option("-c",
                   "--config",
                   dest="config_path",
                   required=False,
                   default=os.getenv("APP_CONFIG",
                                     "/etc/mr-provisioner/config.ini"))
manager.add_command('db', MigrateCommand)


@manager.option("-h", "--host", dest="host", default="127.0.0.1")
@manager.option("-p", "--port", dest="port", type=int, default=5000)
def waitress(host, port):
    "Runs the app with waitress"

    from waitress import serve
    serve(manager.app, listen="%s:%d" % (host, port))


@manager.option("-h", "--host", dest="host", default="127.0.0.1")
예제 #21
0

@MockCommand.command
def vendorProduce():
    VendorProduceMock().mock_bulk()


@MockCommand.command
def user():
    UserMock().mock_bulk()


manager = Manager(create_app)
manager.add_option('-c',
                   '--config',
                   dest='config_cls',
                   default=os.getenv('FLASK_CONFIG_CLASS', 'Development'),
                   required=False)


def shell_context():
    context = dict(app=current_app,
                   db=db,
                   ma=ma,
                   MarketModel=MarketModel,
                   MarketSchema=MarketSchema,
                   MarketVendorModel=MarketVendorModel,
                   VendorModel=VendorModel)
    return context

예제 #22
0
파일: manage.py 프로젝트: soszrg/firefly
from __future__ import absolute_import

# coding=utf-8

from flask_script import Manager, Server, Shell

from firefly.app import create_app

from firefly.models.user import Role, User, SocialConnection


def make_shell_context():
    return {"Role": Role, "User": User, "SocialConnection": SocialConnection}


manager = Manager(create_app)
manager.add_option("-c", "--config", dest="config", required=False)
manager.add_command("shell", Shell(make_context=make_shell_context))
manager.add_command("runserver", Server(use_debugger=True, use_reloader=True, host="0.0.0.0"))

if __name__ == "__main__":
    manager.run()
from flask import current_app
from app.extensions import db
import app.database_initialize as database_initialize
from app import create_app
from app.config import DevelopmentConfig


def create_my_app(config=None):
    return create_app(config='PRODUCTION')


manager = Manager(create_my_app)

manager.add_option('-c',
                   '--config',
                   dest='config',
                   required=False,
                   help='config [LOCAL, DEVELOPMENT, PRODUCTION]')


@manager.command
def initdb():
    db.drop_all()
    db.create_all()

    user = database_initialize.Users(username=u'AdminUser', isAdmin=1)
    user.hash_password('AdminPassword')
    db.session.add(user)
    db.session.commit()

예제 #24
0
@manager.shell
def make_shell_context():
    return dict(app=current_app,
                db=db,
                Site=Site,
                Year=Year,
                Group=Group,
                Schedule=Schedule,
                ScheduleGroupIcal=ScheduleGroupIcal,
                ScheduleImage=ScheduleImage)


manager.add_option('-c',
                   '--config',
                   dest="config",
                   default='dev',
                   choices=('prod', 'dev'))


@manager.command
def runserver():
    """Runs the Flask server"""
    if app.debug:
        app.run(host=app.config['HOST'], port=app.config['PORT'])
    else:
        app.wsgi_app = ProxyFix(app.wsgi_app)
        address = app.config['HOST'], app.config['PORT']
        server = WSGIServer(address, app)
        try:
            print("Server running on port %s:%d. Ctrl+C to quit" % address)
예제 #25
0
                                  app.config['PORT'],
                                  url)
        s.get(url)
        print(url)


@manager.shell
def make_shell_context():
    return dict(app=current_app, db=db, Site=Site, Year=Year, Group=Group,
                Schedule=Schedule, ScheduleGroupIcal=ScheduleGroupIcal,
                ScheduleImage=ScheduleImage)


manager.add_option('-c', '--config',
                   dest="config",
                   required=True,
                   default='dev',
                   choices=('prod', 'dev'))


@manager.command
def runserver():
    """Runs the Flask server"""
    if app.debug:
        app.run(host=app.config['HOST'], port=app.config['PORT'])
    else:
        app.wsgi_app = ProxyFix(app.wsgi_app)
        address = app.config['HOST'], app.config['PORT']
        server = WSGIServer(address, app)
        try:
            print("Server running on port %s:%d. Ctrl+C to quit" % address)
예제 #26
0
from app import create_app
from flask_script import Manager
import database as db
import importlib

from modules.account.models import Account, PasswordReset
from modules.donations.models import Donation
from modules.email_list.models import ListEntry
from modules.security.models import Permission
from modules.volunteer.models import Volunteer, LoggedHours

manager = Manager(create_app)
manager.add_option('-e', '--environment', dest='environment', required=True)

@manager.shell
def shell_ctx():
    return dict(db=db)

@manager.command
def sync_volunteers():
    """Fix any Volunteers where local names differ from account names"""
    volunteers = Volunteer.select().where(Volunteer.account != None)
    print("Syncing {} volunteer(s)".format(volunteers.count()))
    for volunteer in volunteers:
        print(volunteer.full_name)
        volunteer.local_first_name = volunteer.account.first_name
        volunteer.local_last_name = volunteer.account.last_name
        volunteer.save()

@manager.command
def create_db():
예제 #27
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from flask_script import Manager

from osrc import create_app
from osrc.manage import (
    CreateTablesCommand,
    DropTablesCommand,
    UpdateCommand,
)

if __name__ == "__main__":
    manager = Manager(create_app)
    manager.add_option("-f",
                       "--filename",
                       dest="config_filename",
                       required=False)

    manager.add_command("create", CreateTablesCommand())
    manager.add_command("drop", DropTablesCommand())
    manager.add_command("update", UpdateCommand())

    manager.run()
예제 #28
0
#!/usr/bin/env python
import urllib

from flask_script import Manager
from flask_script.commands import Clean, Server, Shell
from app import ApplicationFactory
from flask_migrate import MigrateCommand
from commands.orm import manager as orm_commands
from commands.assets import Build, Watch, LintJS
from commands.user import UserCreate, RoleCreate, RoleAssign, RoleList


manager = Manager(ApplicationFactory.create_application)

manager.add_option('-e', '--env', dest='env', required=False, default='development')


manager.add_command("server", Server())
manager.add_command("shell", Shell())
manager.add_command('clean', Clean())
manager.add_command('db', MigrateCommand)
manager.add_command('orm', orm_commands)
manager.add_command('build', Build())
manager.add_command('watch', Watch())
manager.add_command('lint_js', LintJS())
manager.add_command('create_user', UserCreate())
manager.add_command('create_role', RoleCreate())
manager.add_command('assign_role', RoleAssign())
manager.add_command('list_roles', RoleList())

예제 #29
0
#!/usr/bin/env python
import os
from commands.populate_bros import PopulateBrosCommand
from commands.run_tests import RunTestsCommand
from flask_script import Manager, Server

from application.main.app import app_factory
from flask_migrate import MigrateCommand

if __name__ == '__main__':
    manager = Manager(app_factory)
    manager.add_command('db', MigrateCommand)
    manager.add_command('populate_bros', PopulateBrosCommand)
    manager.add_command('test', RunTestsCommand)
    manager.add_command('runserver', Server(host='0.0.0.0', port=os.environ.get('PORT', 5000)))
    manager.add_option("-n", "--name", dest="app_name", required=False, default='default')
    manager.add_option("-e", "--environment", dest="environment", required=False, default='development')
    manager.run()
예제 #30
0
        migrations = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'migrations', 'versions')

        revisions = [_parse_revision(os.path.join(migrations, filename)) for filename in os.listdir(migrations) if filename.endswith('.py')]
        max_revision = max(revisions)
        db_version = int(version.version_num)
        assert db_version == max_revision, "old database schema found: revision %d. please run '%s db upgrade' to upgrade to revision %d" % (db_version, __file__, max_revision)


def command_app_context():
    app.config.update(SQLALCHEMY_ECHO=False)
    return app.app_context()


manager = Manager(init)

manager.add_option('-c', '--config', dest='configfile', default='openmoves.cfg', required=False)

manager.add_command("runserver", Server(use_debugger=True))
manager.add_command('db', MigrateCommand)
manager.add_command('add-user', AddUser(command_app_context, app_bcrypt))
manager.add_command('import-move', ImportMove(command_app_context))
manager.add_command('delete-move', DeleteMove(command_app_context))
manager.add_command('list-moves', ListMoves(command_app_context))


@app.errorhandler(404)
def error404(error):
    return render_template('_404.html'), 404


@app.route('/import', methods=['GET', 'POST'])
예제 #31
0
파일: manage.py 프로젝트: intgr/lemur
from lemur.users.models import User  # noqa
from lemur.roles.models import Role  # noqa
from lemur.authorities.models import Authority  # noqa
from lemur.certificates.models import Certificate  # noqa
from lemur.destinations.models import Destination  # noqa
from lemur.domains.models import Domain  # noqa
from lemur.notifications.models import Notification  # noqa
from lemur.sources.models import Source  # noqa
from lemur.logs.models import Log  # noqa
from lemur.endpoints.models import Endpoint  # noqa
from lemur.policies.models import RotationPolicy  # noqa
from lemur.pending_certificates.models import PendingCertificate  # noqa
from lemur.dns_providers.models import DnsProvider  # noqa

manager = Manager(create_app)
manager.add_option('-c', '--config', dest='config')

migrate = Migrate(create_app)

REQUIRED_VARIABLES = [
    'LEMUR_SECURITY_TEAM_EMAIL',
    'LEMUR_DEFAULT_ORGANIZATIONAL_UNIT',
    'LEMUR_DEFAULT_ORGANIZATION',
    'LEMUR_DEFAULT_LOCATION',
    'LEMUR_DEFAULT_COUNTRY',
    'LEMUR_DEFAULT_STATE',
    'SQLALCHEMY_DATABASE_URI'
]

KEY_LENGTH = 40
DEFAULT_CONFIG_PATH = '~/.lemur/lemur.conf.py'
예제 #32
0
파일: manage.py 프로젝트: IamFive/reliam2
# -*- coding: utf-8 -*-
#
# Copyright (c) 2011-2013 Woo-cupid(iampurse#vip.qq.com)
#
from os.path import abspath
from flask_script import Manager
from flask.globals import current_app
from reliam.common.app import startup_app, init_db, clear_db

manager = Manager(startup_app)
manager.add_option('-c', '--config', type=abspath, dest='config_folder',
                   default=None)

@manager.command
def initdb():
    ''' Initialize database . '''
    with current_app.app_context():
        init_db()

@manager.command
def cleardb():
    '''Clear database .'''
    with current_app.app_context():
        clear_db()


if __name__ == '__main__':
    manager.run(default_command='runserver')
예제 #33
0
파일: manage.py 프로젝트: dtrodger/s
from app import create_app, db
from app.models import UnderclassPreorder, RequestInfo, RenewedContract, PhotoClass, GraduateCardOrder
from flask_admin import Admin
from flask_admin.contrib.sqla import ModelView
from flask_script import Manager, Shell
from flask_migrate import Migrate, MigrateCommand

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

admin = Admin(app)
admin.add_view(ModelView(UnderclassPreorder, db.session))
admin.add_view(ModelView(RequestInfo, db.session))
admin.add_view(ModelView(RenewedContract, db.session))
admin.add_view(ModelView(PhotoClass, db.session))
admin.add_view(ModelView(GraduateCardOrder, db.session))
manager = Manager(app)
migrate = Migrate(app, db)


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.add_option('-a', '--app', dest='application', default='demo')
manager.add_option('-c', '--config', dest='config', default='default')
# manager.add_command("runserver", Server(use_reloader=True))

if __name__ == '__main__':
    manager.run()
예제 #34
0
@manager.command
def initdb():
    """Init/reset database."""

    db.session.remove()
    db.drop_all(bind=None)
    db.create_all()

    bank = Account(name=u'Bank',
                   description=u'My Bank')
    db.session.add(bank)
    db.session.commit()

    # admin = Admin(
    #         username=u'admin',
    #         email=u'*****@*****.**',
    #         password=u'pw123')
    #
    # db_session.add(admin)
    # db_session.commit()


manager.add_option('-c', '--config',
                   dest="config",
                   required=False,
                   help="config file")

if __name__ == "__main__":
    manager.run()
예제 #35
0
파일: manage.py 프로젝트: amorwilliams/gst
# -*- coding:utf-8 -*-


from flask_script.commands import ShowUrls, Clean, Shell
from flask_script import Manager
from flask_migrate import MigrateCommand
from apps import config, commands
from apps.main import app_factory

manager = Manager(app_factory)
manager.add_option("-n", "--name", dest="app_name", required=False, default=config.project_name)
manager.add_option("-c", "--config", dest="config", required=False, default=config.Dev)

manager.add_command('shell', Shell())
manager.add_command("urls", ShowUrls())
manager.add_command("clean", Clean())

manager.add_command("db", MigrateCommand)

manager.add_command("test", commands.Test())
manager.add_command("create_db", commands.CreateDB())
manager.add_command("drop_db", commands.DropDB())

if __name__ == "__main__":
    manager.run()

예제 #36
0
파일: manage.py 프로젝트: tupy/bolao
            game.team2 = team2
            date_time = _game['date_time']
            #FIXME drop the day of week
            date_time = " ".join(date_time.split()[1:])
            game.time = datetime.datetime.strptime(date_time, '%d/%m/%Y - %H:%M')
            game.place = _game['place']
            game.round = _game['round']
            game.group = _game['group']

            db.session.add(game)
            db.session.commit()


class DropDB(Command):
    """
    Drops database using SQLAlchemy
    """

    def run(self):
        drop_all()


if __name__ == "__main__":
    from bolao.main import app_factory

    manager = Manager(app_factory)
    manager.add_option("-c", "--config", dest="config", required=False, default='Dev')
    manager.add_command("create_db", CreateDB())
    manager.add_command("drop_db", DropDB())
    manager.run()
예제 #37
0
from flask_script import Manager, Server

from foursquare_sample.app import create_app

manager = Manager(create_app)
manager.add_option('-c',
                   '--config',
                   default='Development',
                   required=False,
                   dest='config')
manager.add_command('runserver', Server(threaded=True))

if __name__ == '__main__':
    manager.run()
예제 #38
0
from app import create_app, app_config
from app.database.models import User

logger = logging.getLogger()
handler = logging.StreamHandler(stream=sys.stdout)
handler.formatter = logging.Formatter(
    '%(asctime)s - %(levelname)s - %(name)s - %(funcName)s: %(message)s')
logger.addHandler(handler)
logger.setLevel(app_config[os.getenv('CONFIG', 'production')].LOG_LEVEL)
logger.propagate = True

manager = Manager(create_app)
manager.add_option('-c',
                   '--config',
                   dest='config_name',
                   required=False,
                   default='production')
manager.add_command('db', MigrateCommand)


@manager.command
@manager.option('-u', '--username', dest='username', required=True)
@manager.option('-p', '--password', dest='password', required=True)
@manager.option('-a', '--active', dest='active', default=True)
def create_user(username, password, active=True):
    with manager.app.app_context():
        User.create(username,
                    str(hashlib.sha256(password.encode('utf-8')).hexdigest()),
                    active)
    print('User created!')
예제 #39
0
from flask_script import Manager

from app import create_app, db


manager = Manager(create_app)

# 서버 실행
if __name__ == '__main__':
    manager.add_option('-c', '--config', dest='config', required=False, default='config')
    manager.run()
예제 #40
0
from itertools import chain
from datetime import date, timedelta
from urllib.parse import urlsplit

from flask import current_app as app
from flask_script import Server, Manager

from app import create_app, db, utils
from app.models import Todo
from config import Config

BASEDIR = p.dirname(__file__)
DEF_PORT = Config.DEF_PORT

manager = Manager(create_app)
manager.add_option(
    '-m', '--cfgmode', dest='config_mode', default='Development')
manager.add_option('-f', '--cfgfile', dest='config_file', type=p.abspath)
manager.main = manager.run  # Needed to do `manage <command>` from the cli


@manager.option('-h', '--host', help='The server host')
@manager.option('-p', '--port', help='The server port')
@manager.option(
    '-t', '--threaded', help='Run multiple threads', action='store_true')
def runserver(live=False, offline=False, timeout=None, **kwargs):
    """Runs the flask development server

    Overrides the built-in `runserver` behavior
    """
    with app.app_context():
        if app.config.get('SERVER'):
예제 #41
0
# -*- coding:utf-8 -*-

from flask_script import Manager

import commands

if __name__ == "__main__":
    from main import app_factory
    import config

    manager = Manager(app_factory)
    manager.add_option("-n",
                       "--name",
                       dest="app_name",
                       required=False,
                       default=config.project_name)
    manager.add_option("-c",
                       "--config",
                       dest="config",
                       required=False,
                       default=config.Dev)
    manager.add_command("test", commands.Test())
    manager.add_command("create_db", commands.CreateDB())
    manager.add_command("drop_db", commands.DropDB())
    manager.run()
예제 #42
0
from flask_script import Manager

from config import Config
from app import create_app
from app.api import add_report, load_report, remove_report, get_status
from app.utils import TODAY
from app.helpers import log, exception_hook

BASEDIR = p.dirname(__file__)
DEF_PORT = 5000
DATE_FORMAT = Config.S3_DATE_FORMAT
DAYS = Config.DAYS

manager = Manager(create_app)
manager.add_option("-m",
                   "--cfgmode",
                   dest="config_mode",
                   default="Development")
manager.add_option("-f", "--cfgfile", dest="config_file", type=p.abspath)
manager.main = manager.run  # Needed to do `manage <command>` from the cli

logger = gogo.Gogo(__name__).logger


@manager.option("-h", "--host", help="The server host")
@manager.option("-p", "--port", help="The server port", default=DEF_PORT)
@manager.option("-t",
                "--threaded",
                help="Run multiple threads",
                action="store_true")
def serve(port, **kwargs):
    """Runs the flask development server"""
예제 #43
0
    def test_access_dashboard_with_login(self):
        # Login
        user = dict(email="*****@*****.**", password="******")
        self.client.post("/login", data=user)
        # Access search result
        response = self.client.get("/dashboard")
        redirect = response.location
        assert response.status_code == 200
        assert redirect is None

    def test_post_search_with_login(self):
        # Login
        user = dict(email="*****@*****.**", password="******")
        self.client.post("/login", data=user)
        # Post search
        data = dict(tipoArquivo='Prova',
                    disciplina='',
                    ano='',
                    semestre='',
                    professor='',
                    departamento='')
        response = self.client.post("/pesquisar", data=data)
        redirect = parse.urlparse(response.location).path
        assert response.status_code == 302
        assert redirect == "/pesquisa/result"


manager = Manager(application.app)
manager.add_option('-c', '--config', dest='config', required=False)
예제 #44
0
파일: manage.py 프로젝트: level12/webgrid
    option_list = (
        Option('--clear', default=False, dest='clear', action="store_true",
               help=_('DROP all DB objects first')),
    )

    def run(self, clear):
        if clear:
            clear_db()
            print(_('- db cleared'))

        model.load_db()
        print(_('- db loaded'))


manager = Manager(create_app)
manager.add_option('-c', dest='config', default='Dev',
                   help=_('flask configuration to use'), required=False)
manager.add_command('create-db', CreateDB())


@manager.command
def list_routes(name='list-routes'):
    output = []
    for rule in flask.current_app.url_map.iter_rules():
        methods = ','.join(rule.methods)
        line = urllib.unquote("{:50s} {:20s} {}".format(rule.endpoint, methods, rule))
        output.append(line)

    for line in sorted(output):
        print(line)

예제 #45
0
from flask_script import Manager
from ariadne_nda import create_app
from ariadne_nda.logging import config_cli_logging

config_cli_logging()
app = create_app
manager = Manager(app)
manager.add_option('-c', '--config', dest='config_level', default='default',
                   required=False)
manager.set_defaults()
예제 #46
0
파일: script.py 프로젝트: pib/piblog
from flask_frozen import Freezer
from flask_script import Command, Manager
from . import create_app, generators


manager = Manager(create_app)

manager.add_option(
    '-c', '--config', dest='config', required=False, default='piblog.cfg',
    help='Specify an alternative config file (default: "piblog.cfg")')
manager.add_option(
    '-D', '--debug-toolbar', dest='debug_toolbar', action='store_true',
    default=False, help='Enable Flask-DebugToolbar if installed')
manager.add_option(
    '-i', '--instance-path', dest='instance_path', required=False,
    default='.', help='Path containing site config (default: ".")')


class FreezeCommand(Command):

    'Freeze the site to static files.'

    def handle(self, app):
        freezer = Freezer(app)
        freezer.register_generator(generators.theme_static)
        freezer.freeze()

manager.add_command('freeze', FreezeCommand())


def run():
예제 #47
0
from subprocess import call, check_call, CalledProcessError

try:
    from urllib.parse import urlsplit
except ImportError:
    from urlparse import urlsplit

from app import create_app
from flask import current_app as app
from flask_script import Server, Manager

BASEDIR = p.dirname(__file__)
DEF_PORT = 5000

manager = Manager(create_app)
manager.add_option(
    '-m', '--cfgmode', dest='config_mode', default='Development')
manager.add_option('-f', '--cfgfile', dest='config_file', type=p.abspath)
manager.main = manager.run  # Needed to do `manage <command>` from the cli


@manager.option('-h', '--host', help='The server host')
@manager.option('-p', '--port', help='The server port')
@manager.option(
    '-t', '--threaded', help='Run multiple threads', action='store_true')
def runserver(live=False, offline=False, timeout=None, **kwargs):
    # Overriding the built-in `runserver` behavior
    """Runs the flask development server"""
    with app.app_context():
        if app.config.get('SERVER'):
            parsed = urlsplit(app.config['SERVER'])
            host, port = parsed.netloc, parsed.port or DEF_PORT
예제 #48
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from flask_script import Manager, Server
from flask_script.commands import ShowUrls
from configs.config import E, APP_NAME

import application

app = application.create_app

manager = Manager(app)
manager.add_option('-c', '--config', dest='config', required=False, choices=E)
manager.add_option('-n',
                   '--name',
                   dest='app_name',
                   required=False,
                   choices=APP_NAME)

manager.add_command("showurls", ShowUrls())


@manager.shell
def make_shell_context():
    """Create a python CLI.
    return: Default import object
    type: `Dict`
    
    """
    from application.extensions import db
    import application.models as Models
    return dict(app=app, db=db, User=Models.User)
예제 #49
0
from flask import current_app
from flask_script import Manager, Shell
from flask_migrate import MigrateCommand

from labelingbot import create_app, db
from labelingbot.models import User


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


manager = Manager(create_app)
manager.add_option('-c',
                   '--config',
                   dest='config_name',
                   required=False,
                   default=os.getenv('LABELING_BOT_CONFIG') or 'default')
manager.add_command('shell', Shell(make_context=make_shell_context))
manager.add_command('db', MigrateCommand)


@manager.command
def init_db():
    from labelingbot import models
    db.create_all()


if __name__ == "__main__":
    manager.run()
예제 #50
0
from lemur.authorities.models import Authority  # noqa
from lemur.certificates.models import Certificate  # noqa
from lemur.destinations.models import Destination  # noqa
from lemur.domains.models import Domain  # noqa
from lemur.notifications.models import Notification  # noqa
from lemur.sources.models import Source  # noqa
from lemur.logs.models import Log  # noqa
from lemur.endpoints.models import Endpoint  # noqa
from lemur.policies.models import RotationPolicy  # noqa
from lemur.pending_certificates.models import PendingCertificate  # noqa
from lemur.dns_providers.models import DnsProvider  # noqa

from sqlalchemy.sql import text

manager = Manager(create_app)
manager.add_option("-c", "--config", dest="config_path", required=False)

migrate = Migrate(create_app)

REQUIRED_VARIABLES = [
    "LEMUR_SECURITY_TEAM_EMAIL",
    "LEMUR_DEFAULT_ORGANIZATIONAL_UNIT",
    "LEMUR_DEFAULT_ORGANIZATION",
    "LEMUR_DEFAULT_LOCATION",
    "LEMUR_DEFAULT_COUNTRY",
    "LEMUR_DEFAULT_STATE",
    "SQLALCHEMY_DATABASE_URI",
]

KEY_LENGTH = 40
DEFAULT_CONFIG_PATH = "~/.lemur/lemur.conf.py"
예제 #51
0
파일: manage.py 프로젝트: rr4/laniakea
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program.

from flask_script import Manager
from lkweb import create_app
from lkweb.config import DebugConfig

app = create_app(config=DebugConfig)
manager = Manager(app)


@manager.command
def run():
    """Run on local machine."""

    app.run()


manager.add_option('-c',
                   '--config',
                   dest='config',
                   required=False,
                   help="config file")

if __name__ == '__main__':
    manager.run()
예제 #52
0
파일: manage.py 프로젝트: Emercoin/emcweb
from flask_script import Manager
from flask_migrate import MigrateCommand

from emcweb import flask_app
from emcweb.exts import connection

__author__ = 'Aspanta Limited'
__email__ = '*****@*****.**'


manager = Manager(flask_app.create_app)
manager.add_command('db', MigrateCommand)


@manager.command
def init():
    connection.drop_all()
    connection.create_all()


@manager.command
def test():
    tests = unittest.defaultTestLoader.discover(os.path.join(os.getcwd(), 'tests'))
    unittest.TextTestRunner().run(tests)


manager.add_option('-c', '--config', help='Config file', dest='config')

if __name__ == '__main__':
    manager.run()
예제 #53
0
from flask_migrate import Migrate
from flask_migrate import MigrateCommand
from flask_script import Manager

from collector.api import log
from collector.api.app import app
from collector.api.db.model import *


def configure_app(mode=None):
    mode_map = {
        'test': 'collector.api.config.Testing',
        'prod': 'collector.api.config.Production'
    }
    app.config.from_object(mode_map.get(mode))
    log.init_logger()
    return app


manager = Manager(configure_app)
manager.add_option('--mode', help="Acceptable modes. Default: 'test'",
                   choices=('test', 'prod'), default='prod', dest='mode')

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


if __name__ == '__main__':
    manager.run()