Exemple #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()
Exemple #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)
Exemple #3
0
def main():
    manager.add_command("start", LemurServer())
    manager.add_command("runserver", Server(host='127.0.0.1'))
    manager.add_command("clean", Clean())
    manager.add_command("show_urls", ShowUrls())
    manager.add_command("db", MigrateCommand)
    manager.add_command("init", InitializeApp())
    manager.add_command("create_user", CreateUser())
    manager.add_command("create_role", CreateRole())
    manager.add_command("provision_elb", ProvisionELB())
    manager.run()
Exemple #4
0
def main():
    manager.add_command("start", LemurServer())
    manager.add_command("runserver", Server(host='127.0.0.1', threaded=True))
    manager.add_command("clean", Clean())
    manager.add_command("show_urls", ShowUrls())
    manager.add_command("db", MigrateCommand)
    manager.add_command("init", InitializeApp())
    manager.add_command("create_user", CreateUser())
    manager.add_command("reset_password", ResetPassword())
    manager.add_command("create_role", CreateRole())
    manager.add_command("source", source_manager)
    manager.add_command("report", Report())
    manager.add_command("certificate", certificate_manager)
    manager.run()
Exemple #5
0
def main():
    manager.add_command("start", LemurServer())
    manager.add_command("runserver", Server(host='127.0.0.1', threaded=True))
    manager.add_command("clean", Clean())
    manager.add_command("show_urls", ShowUrls())
    manager.add_command("db", MigrateCommand)
    manager.add_command("init", InitializeApp())
    manager.add_command("create_user", CreateUser())
    manager.add_command("reset_password", ResetPassword())
    manager.add_command("create_role", CreateRole())
    manager.add_command("provision_elb", ProvisionELB())
    manager.add_command("rotate_elbs", RotateELBs())
    manager.add_command("rolling", Rolling())
    manager.add_command("sources", Sources())
    manager.add_command("report", Report())
    manager.run()
Exemple #6
0
def register_commands(manager):
    '''Register all core commands'''
    manager.add_command('clean', Clean())
    manager.add_command('urls', ShowUrls())

    settings = os.environ.get('UDATA_SETTINGS', join(os.getcwd(), 'udata.cfg'))
    manager.add_command(
        'serve',
        Server(port=7000,
               use_debugger=True,
               use_reloader=True,
               threaded=True,
               extra_files=[settings]))

    # Load all commands submodule
    for filename in iglob(join(dirname(__file__), '[!_]*.py')):
        module = splitext(basename(filename))[0]
        try:
            __import__('udata.commands.{0}'.format(module))
        except Exception as e:
            log.error('Unable to import %s: %s', module, e)

    # Load all core modules commands
    import udata.core.metrics.commands  # noqa
    import udata.core.user.commands  # noqa
    import udata.core.dataset.commands  # noqa
    import udata.core.organization.commands  # noqa
    import udata.search.commands  # noqa
    import udata.core.spatial.commands  # noqa
    import udata.core.jobs.commands  # noqa
    import udata.core.badges.commands  # noqa
    import udata.api.commands  # noqa
    import udata.harvest.commands  # noqa
    import udata.features.territories.commands  # noqa
    import udata.linkchecker.commands  # noqa

    # Dynamic module commands loading
    for plugin in manager.app.config['PLUGINS']:
        name = 'udata_{0}.commands'.format(plugin)
        try:
            __import__(name)
        except ImportError as e:
            pass
        except Exception as e:
            log.error('Error during import of %s: %s', name, e)
Exemple #7
0
def main():
    manager.add_command("start", LemurServer())
    manager.add_command("runserver", Server(host='127.0.0.1', threaded=True))
    manager.add_command("clean", Clean())
    manager.add_command("show_urls", ShowUrls())
    manager.add_command("db", MigrateCommand)
    manager.add_command("init", InitializeApp())
    manager.add_command("create_user", CreateUser())
    manager.add_command("reset_password", ResetPassword())
    manager.add_command("create_role", CreateRole())
    manager.add_command("source", source_manager)
    manager.add_command("certificate", certificate_manager)
    manager.add_command("notify", notification_manager)
    manager.add_command("endpoint", endpoint_manager)
    manager.add_command("report", report_manager)
    manager.add_command("policy", policy_manager)
    manager.add_command("pending_certs", pending_certificate_manager)
    manager.add_command("dns_providers", dns_provider_manager)
    manager.run()
Exemple #8
0
#!/usr/bin/env python
from flask_script import Manager
from flask_script.commands import Server, Shell, ShowUrls, Clean

from flask_application import app
from flask_application.test.script import RunTests

__author__ = "Antti Kallonen"
__copyright__ = "Copyright 2016, Tampere University of Technology"
__license__ = "MIT"
__version__ = "1.0"
__email__ = "*****@*****.**"

manager = Manager(app)
manager.add_command("run_server",
                    Server(host="0.0.0.0", port=9000, use_reloader=True))
manager.add_command("show_urls", ShowUrls())
manager.add_command("clean", Clean())
manager.add_command('run_tests', RunTests())

if __name__ == "__main__":
    manager.run()
    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)
manager.add_command('serve', server_command)
manager.add_command('shell', shell_command)
manager.add_command('routes', routes_command)
Exemple #10
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()
Exemple #11
0
from app import create_app, db
from app.models import User
from flask_script import Manager, Shell
from flask_script.commands import Server, ShowUrls

app = create_app()
manager = Manager(app)

manager.add_command('url', ShowUrls())

manager.add_command('server', Server(
    host=app.config.get('HOST', 'localhost'),
    port=app.config.get('PORT', 7002)
))


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


manager.add_command("shell", Shell(make_context=make_shell_context))


"""
python manager.py shell
user = User(username="******")
user.set_password("123456")
db.session.add(user)
db.session.commit()
"""
if __name__ == '__main__':
Exemple #12
0
from app import create_app
from flask_script import Manager
from flask_script.commands import Server
from flask_migrate import Migrate, MigrateCommand
from app.models import db

from app.config import SubServer, SubShowUrls
import app.models

ft_app = create_app()
ft_manager = Manager(ft_app)
ft_manager.add_command('runserver',
                       SubServer(ft_app, host='127.0.0.1', port=5100))
ft_manager.add_command('urls', SubShowUrls(ft_app))


def make_shell_context():
    return dict(app=app, db=db, models=app.models)


xapp = create_app()
manager = Manager(xapp)
migrate = Migrate(xapp, db, render_as_batch=True)

manager.add_command('db', MigrateCommand)
manager.add_command('runserver', Server(host='127.0.0.1'))

if __name__ == '__main__':
    manager.run()
Exemple #13
0
#!/usr/bin/env python3

from flask_script import Manager
from flask_script.commands import Server, ShowUrls, Clean
from config import config
from webapp import create_app

app = create_app(config['dev'])

manager = Manager(app)

manager.add_command('runserver', Server())
manager.add_command('showurls', ShowUrls())
manager.add_command('clean', Clean())

if __name__ == '__main__':
    manager.run()
Exemple #14
0
from flask_script import Manager, Shell
from flask_script.commands import ShowUrls, Clean, Server
from flask_migrate import Migrate, MigrateCommand

from app import create_app, db

app = create_app(os.getenv("FLASK_CONFIG", 'default'))
manager = Manager(app)
migrate = Migrate(app, db)


def _make_shell_context():
    return dict(app=app, db=db)


@manager.command
def test():
    import unittest
    tests = unittest.TestLoader().discover("tests")
    unittest.TextTestRunner(verbosity=2).run(tests)


manager.add_command("shell", Shell(make_context=_make_shell_context))
manager.add_command("db", MigrateCommand)
manager.add_command("show-urls", ShowUrls())
manager.add_command("clean", Clean())
manager.add_command("runserver", Server())

if __name__ == '__main__':
    manager.run()
Exemple #15
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()
Exemple #16
0
        CleanSamples, AddImageDB, CleanModels, GetSamples, ResetCheckedNotAnnotated

from webtools.tests.script import RunTests


def _make_context():
    return dict(app=app, db=app.db, models=models)


if __name__ == '__main__':
    migrate = Migrate(app, app.db)
    manager = Manager(app, with_default_commands=False)

    manager.add_command('shell', Shell(make_context=_make_context))
    manager.add_command('run_dev_server',
                        Server(use_reloader=True, threaded=True))
    manager.add_command('show_urls', ShowUrls())
    manager.add_command('clean_pyc', Clean())

    manager.add_command('db', MigrateCommand)
    manager.add_command('db_reset', ResetDb)
    manager.add_command('db_command', DatabaseCommand)
    manager.add_command('add_imdb', AddImageDB)
    manager.add_command('clean_models', CleanModels)
    manager.add_command('get_samples', GetSamples)
    manager.add_command('reset_check', ResetCheckedNotAnnotated)

    manager.add_command('clean_waste_images', CleanWasteImages)
    manager.add_command('clean_cache', CleanCache)
    manager.add_command('clean_samples', CleanSamples)
Exemple #17
0
from application import manager, db

from flask_script.commands import ShowUrls, Server

from flask_migrate import MigrateCommand
import os
import sys
from models import *
from flask import current_app

manager.add_command('db', MigrateCommand)
manager.add_command('urls', ShowUrls)
manager.add_command('runserver', Server(port=8000))


@manager.command
def init_db():
    '''
    this command is drop databases
    :return:
    '''
    command = input(
        'Are you sure? You will init your database if you input yes or y db start init:\n'
    )
    if command.lower().strip() == 'yes' or command.lower().strip() == 'y':
        db.drop_all()
        db.create_all()
        print('db init finsh')


@manager.command
Exemple #18
0
# -*- coding:utf-8 -*-
import sys

from flask_script import Manager
from flask_script.commands import Server
from flask_migrate import Migrate, MigrateCommand

from application import db
from application import create_app

app = create_app()

migrate = Migrate(app, db)

manager = Manager(app)

manager.add_command("db", MigrateCommand)

manager.add_command("runserver",
                    Server(host="0.0.0.0", port=8042, threaded=True))

if __name__ == "__main__":

    # print("[{command}]realibox app 开始运行".format(command=sys.argv[1]))

    manager.run()
Exemple #19
0
# -*- coding:utf-8 -*-
import sys

from flask_script import Manager
from flask_script.commands import Server
from flask_migrate import Migrate, MigrateCommand

from application import db
from application import create_app

app = create_app()

migrate = Migrate(app, db)

manager = Manager(app)

manager.add_command("db", MigrateCommand)

manager.add_command("runserver", Server(
    host="0.0.0.0", port=8042, threaded=True))

if __name__ == "__main__":

    # print("[{command}]realibox app 开始运行".format(command=sys.argv[1]))

    manager.run()
Exemple #20
0
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)


@manager.command