Python flask_script 模块,Manager() 实例源码

我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用flask_script.Manager()

项目:repocribro    作者:MarekSuchanek    | 项目源码 | 文件源码
def run():
    """Run the CLI manager for the web application

    .. todo:: allow extension add options & commands,
              separate create and run part of function
              command for checking config
    """
    manager = flask_script.Manager(create_app)
    manager.add_option('-c', '--config', dest='cfg_files',
                       required=False, action='append',
                       default=['DEFAULT'])
    manager.add_option('-v', '--version', action='version',
                       version='{} v{}'.format(PROG_NAME, VERSION))

    manager.add_command('db', flask_migrate.MigrateCommand)
    manager.add_command('db-create', DbCreateCommand)
    manager.add_command('repocheck', RepocheckCommand)
    manager.add_command('assign-role', AssignRoleCommand)
    manager.add_command('check-config', CheckConfigCommand)

    manager.run()
项目:apizen    作者:blackmatrix7    | 项目源码 | 文件源码
def __call__(self, app=None, **kwargs):
        """
        ???Manager????Options will be ignored.???
        ???flask-script?Manager??app??????????
        ???????
        """
        if app is None:
            app = self.app
            if app is None:
                raise Exception("There is no app here. This is unlikely to work.")

        if isinstance(app, Flask):
            return app

        app = app(**kwargs)
        self.app = app
        return app
项目:apizen    作者:blackmatrix7    | 项目源码 | 文件源码
def __call__(self, app=None, **kwargs):
        """
        ???Manager????Options will be ignored.???
        ???flask-script?Manager??app??????????
        ???????
        """
        if app is None:
            app = self.app
            if app is None:
                raise Exception("There is no app here. This is unlikely to work.")

        if isinstance(app, Flask):
            return app

        app = app(**kwargs)
        self.app = app
        return app
项目:docket    作者:rocknsm    | 项目源码 | 文件源码
def manager(self):
        return Manager(self.flask_app)
项目:fireq    作者:superdesk    | 项目源码 | 文件源码
def main():
    import sys
    from flask_script import Manager
    from superdesk import COMMANDS
    from superdesk.ws import create_server

    if len(sys.argv) == 2 and sys.argv[1] == 'ws':
        create_server(application.config)
    else:
        manager = Manager(application)
        manager.run(COMMANDS)
项目:flask-pw    作者:klen    | 项目源码 | 文件源码
def manager(self):
        """Integrate a Flask-Script."""
        from flask_script import Manager, Command

        manager = Manager(usage="Migrate database.")
        manager.add_command('create', Command(self.cmd_create))
        manager.add_command('migrate', Command(self.cmd_migrate))
        manager.add_command('rollback', Command(self.cmd_rollback))
        manager.add_command('list', Command(self.cmd_list))
        manager.add_command('merge', Command(self.cmd_merge))

        return manager
项目:flask-ci    作者:vicenteneto    | 项目源码 | 文件源码
def test_with_default_commands(self):
        manager = Manager(self.app)
        manager.set_defaults()

        assert 'runserver' in manager._commands
        assert 'shell' in manager._commands