コード例 #1
0
ファイル: tests.py プロジェクト: imfht/flaskapps
    def test_no_help(self, capsys):
        """
        Tests that erasing --help really works.
        """

        manager = Manager(self.app)
        manager.help_args = ()

        @manager.command
        def hello(name='fred'):
            'Prints your name'
            print('hello ' + name)
        assert 'hello' in manager._commands

        code = run('manage.py --help hello', manager.run)
        out, err = capsys.readouterr()
        print(out)
        assert 'too many arguments' in err

        code = run('manage.py hello --help', manager.run)
        out, err = capsys.readouterr()
        print(out)
        assert 'too many arguments' in err
コード例 #2
0
ファイル: main.py プロジェクト: n0d3tr/Mycro
from router.web import app
from config.config import bcolors
from config.filesystem import makeDaemon, init
from flask_script import Command, Manager, Option
import os

manager = Manager(app)
manager.help_args = ('-?', '--help')


@manager.option('-n', '--name', help='Daemon name')
def daemon(name):
    """Daemon name"""
    makeDaemon(name)


@manager.option('-t', '--test', help='Daemon test', default=False)
def test(test):
    """Daemon name"""

    # all_functions = inspect.getmembers('app/Http/*', inspect.isfunction)
    # for item in all_functions:
    # print(item)


if __name__ == "__main__":
    init()
    manager.run()
コード例 #3
0
ファイル: manage.py プロジェクト: James6xie/fm-orchestrator
def create_app(debug=False, verbose=False, quiet=False):
    # logging (intended for flask-script, see manage.py)
    log = logging.getLogger(__name__)
    if debug:
        log.setLevel(level_flags["debug"])
    elif verbose:
        log.setLevel(level_flags["verbose"])
    elif quiet:
        log.setLevel(level_flags["quiet"])

    return app


manager = Manager(create_app)
help_args = ("-?", "--help")
manager.help_args = help_args
migrations_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)),
                              'migrations')
migrate = flask_migrate.Migrate(app, db, directory=migrations_dir)
manager.add_command("db", flask_migrate.MigrateCommand)
manager.add_option("-d", "--debug", dest="debug", action="store_true")
manager.add_option("-v", "--verbose", dest="verbose", action="store_true")
manager.add_option("-q", "--quiet", dest="quiet", action="store_true")


def console_script_help(f):
    @wraps(f)
    def wrapped(*args, **kwargs):
        import sys

        if any([arg in help_args for arg in sys.argv[1:]]):