Пример #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 register_manager(manager):
    """Register all manager plugins and default commands with the manager."""
    from six.moves.urllib.parse import urlparse
    managers = RegistryProxy('managers', ModuleAutoDiscoveryRegistry, 'manage')

    with manager.app.app_context():
        for script in find_modules('invenio.base.scripts'):
            manager.add_command(
                script.split('.')[-1], import_string(script + ':manager'))
        for script in managers:
            if script.__name__ == 'invenio.base.manage':
                continue
            manager.add_command(
                script.__name__.split('.')[-2], getattr(script, 'manager'))

    manager.add_command("clean", Clean())
    manager.add_command("show-urls", ShowUrls())
    manager.add_command("shell", Shell())
    parsed_url = urlparse(manager.app.config.get('CFG_SITE_URL'))
    host = manager.app.config.get('SERVER_BIND_ADDRESS', parsed_url.hostname
                                  or '127.0.0.1')
    port = manager.app.config.get('SERVER_BIND_PORT', parsed_url.port or 80)
    runserver = Server(host=host, port=port)
    manager.add_command("runserver", runserver)

    # FIXME separation of concerns is violated here.
    from invenio.ext.collect import collect
    collect.init_script(manager)

    from invenio.ext.assets import command, bower
    manager.add_command("assets", command)
    manager.add_command("bower", bower)
Пример #3
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()
Пример #4
0
"""Management commands."""

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

from pygotham.factory import create_app
from pygotham.manage import CreateAdmin, CreateEvent, CreateUser

manager = Manager(create_app(__name__, ''), with_default_commands=False)
manager.add_command('create_admin', CreateAdmin())
manager.add_command('create_event', CreateEvent())
manager.add_command('create_user', CreateUser())
manager.add_command('db', MigrateCommand)
manager.add_command('shell', Shell())

if __name__ == '__main__':
    manager.run()
Пример #5
0
from flask_script import Manager
from flask_script.commands import Server, Shell, ShowUrls, Clean

from exchange_app import app

manager = Manager(app)
manager.add_command("shell", Shell())
manager.add_command("runserver", Server(use_reloader=True))
manager.add_command("show_urls", ShowUrls())
manager.add_command("clean", Clean())

if __name__ == "__main__":
    manager.run()
Пример #6
0
#!/usr/bin/env python
from flask_script import Manager
from flask_script.commands import Server, Shell, ShowUrls, Clean
from flask_security.script import CreateUserCommand, AddRoleCommand,\
    RemoveRoleCommand, ActivateUserCommand, DeactivateUserCommand

from flask_application import app
from flask_application.script import ResetDB, PopulateDB
from flask_application.tests.script import RunTests

manager = Manager(app)
manager.add_command("shell", Shell(use_ipython=True))
manager.add_command("runserver", Server(use_reloader=True))
manager.add_command("show_urls", ShowUrls())
manager.add_command("clean", Clean())

manager.add_command("reset_db", ResetDB())
manager.add_command("populate_db", PopulateDB())

manager.add_command('create_user', CreateUserCommand())
manager.add_command('add_role', AddRoleCommand())
manager.add_command('remove_role', RemoveRoleCommand())
manager.add_command('deactivate_user', DeactivateUserCommand())
manager.add_command('activate_user', ActivateUserCommand())

manager.add_command('run_tests', RunTests())

if __name__ == "__main__":
    manager.run()
Пример #7
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()
Пример #8
0
        import sys

        os.environ['FLASK_COVERAGE'] = '1'
        os.execvp(sys.executable, [sys.executable] + sys.argv)

    import unittest

    tests = unittest.TestLoader().discover('tests')
    unittest.TextTestRunner(verbosity=2).run(tests)
    if COV:
        COV.stop()
        COV.save()
        print('Coverage Summary:')
        COV.report()
        basedir = os.path.abspath(os.path.dirname(__file__))
        covdir = os.path.join(basedir, 'tmp/coverage')
        COV.html_report(directory=covdir)
        print('HTML version: file://%s/index.html' % (covdir, ))
        COV.erase()


# Turn on debugger by default and reloader
manager.add_command(
    "runserver", Server(use_debugger=True, use_reloader=True, host='0.0.0.0'))
manager.add_command('db', MigrateCommand)
manager.add_command('shell', Shell(make_context=make_shell_context))
manager.add_command('show_urls', ShowUrls)

if __name__ == "__main__":
    manager.run()
Пример #9
0
                Trip=Trip,
                Shape=Shape,
                Stop=Stop,
                StopSeq=StopSeq,
                TripStartTime=TripStartTime,
                CalendarDate=CalendarDate,
                Calendar=Calendar,
                Agency=Agency,
                FeedInfo=FeedInfo,
                Feed=Feed,
                User=User,
                Role=Role,
                ShapePath=ShapePath)


manager = Manager(app)
migrate = Migrate(app, db)

manager.add_command('buildfeed', BuildFeed)
manager.add_command('export', ExportCSV)
manager.add_command('dumpdata', DumpData)
manager.add_command('loaddata', LoadData)
manager.add_command('deploy', Deploy)
manager.add_command('migrate_shapes', MigrateShapes)
manager.add_command("shell", Shell(make_context=make_shell_context))
manager.add_command('db', MigrateCommand)
manager.add_command('clean', Clean)

if __name__ == '__main__':
    manager.run()
Пример #10
0
@cache_manager.command
def clear():
    """clear the cache"""
    cache.clear()


asset_manager = ManageAssets(assets_env)
asset_manager.help = 'run commands for assets'


def _shell_context():
    return dict(current_app=current_app, g=g, db=db, cache=cache,
                Series=Series, Chapter=Chapter)

shell_command = Shell(make_context=_shell_context)
shell_command.help = 'run a Python shell inside the Flask app context'


server_command = Server()
server_command.help = 'run the Flask development server i.e. app.run()'


routes_command = ShowUrls()
routes_command.help = 'print all of the URL mathcing routes for the project'


manager = Manager()
manager.add_command('db', db_manager)
manager.add_command('cache', cache_manager)
manager.add_command('assets', asset_manager)
Пример #11
0
def main(create_app_func=None):
    
    if not create_app_func:
        from shortener_url.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, **kwargs):
            
            #print("kwargs : ", kwargs)
            #{'ssl_key': None, 'ssl_crt': None}

            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('SHORTURL_SETTINGS', 'shortener_url.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)
        )
        manager.add_command("debug-server", Server(
                        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())
    
    from flask_security import script
    manager.add_command('auth-create-user', script.CreateUserCommand())
    manager.add_command('auth-create-role', script.CreateRoleCommand())
    manager.add_command('auth-add-role', script.AddRoleCommand())
    manager.add_command('auth-remove-role', script.RemoveRoleCommand())
    manager.add_command('auth-activate-user', script.ActivateUserCommand())
    manager.add_command('auth-deactivate-user', script.DeactivateUserCommand())
    
    manager.run()
Пример #12
0

asset_manager = ManageAssets(assets_env)
asset_manager.help = 'run commands for assets'


def _shell_context():
    return dict(current_app=current_app,
                g=g,
                db=db,
                cache=cache,
                Series=Series,
                Chapter=Chapter)


shell_command = Shell(make_context=_shell_context)
shell_command.help = 'run a Python shell inside the Flask app context'

server_command = Server()
server_command.help = 'run the Flask development server i.e. app.run()'

routes_command = ShowUrls()
routes_command.help = 'print all of the URL mathcing routes for the project'

manager = Manager()
manager.add_command('db', db_manager)
manager.add_command('cache', cache_manager)
manager.add_command('assets', asset_manager)
manager.add_command('serve', server_command)
manager.add_command('shell', shell_command)
manager.add_command('routes', routes_command)