Esempio n. 1
0
def _run_deploy(dest, sudo=False, ask_sudo_pass=False):
    prepare_source_package()
    ansible = ensure_ansible()
    click.echo(click.style("Running deployment on {0!r}. This may take a while...".format(dest), fg='magenta'))

    if dest == "vagrant":
        # Vagrant will invoke ansible
        environ = os.environ.copy()
        environ["PATH"] = "{}:{}".format(os.path.dirname(ansible), environ["PATH"])
        # "vagrant up --provision" doesn't call provision if the virtual machine is already up,
        # so we have to call vagrant provision explicitly
        subprocess.check_call('vagrant up', shell=True, env=environ)
        subprocess.check_call('vagrant provision', shell=True, env=environ)
    else:
        cmd = [ansible, "-i",
               from_project_root("ansible", "inventories", dest)]
        if dest in ("localhost",):
            cmd.extend(["-c", "local"])
            if dest == "localhost":
                cmd.append("--sudo")

        if sudo:
            cmd.append('--sudo')

        if ask_sudo_pass:
            cmd.append('--ask-sudo-pass')

        cmd.append(from_project_root("ansible", "site.yml"))
        subprocess.check_call(cmd)
Esempio n. 2
0
def _run_tmux_frontend(port):
    tmuxp = os.path.join(os.path.dirname(sys.executable), 'tmuxp')
    os.execve(
        tmuxp, [tmuxp, 'load',
                from_project_root('_lib', 'frontend_tmux.yml')],
        dict(os.environ,
             TESTSERVER_PORT=str(port),
             CONFIG_DIRECTORY=from_project_root("conf.d")))
Esempio n. 3
0
def _run_tmux_frontend(port):
    tmuxp = from_env_bin('tmuxp')
    os.execve(
        tmuxp, [tmuxp, 'load',
                from_project_root('_lib', 'frontend_tmux.yml')],
        dict(os.environ,
             TESTSERVER_PORT=str(port),
             CONFIG_DIRECTORY=from_project_root("conf.d")))
Esempio n. 4
0
def deploy(dest, sudo, ask_sudo_pass, vagrant_machine, inventory):
    prepare_source_package()
    ansible = ensure_ansible()

    if dest == "vagrant":
        # Vagrant will invoke ansible
        environ = os.environ.copy()
        environ["PATH"] = "{}:{}".format(os.path.dirname(ansible),
                                         environ["PATH"])
        # "vagrant up --provision" doesn't call provision if the virtual machine is already up,
        # so we have to call vagrant provision explicitly
        click.echo(
            click.style(
                "Running deployment on Vagrant. This may take a while...",
                fg='magenta'))
        subprocess.check_call('vagrant up ' + vagrant_machine,
                              shell=True,
                              env=environ)
        subprocess.check_call('vagrant provision ' + vagrant_machine,
                              shell=True,
                              env=environ)
    else:
        if dest == "custom":
            if inventory is None:
                raise click.ClickException(
                    "-i/--inventory should be specified together with \"--dest custom\""
                )
            if not os.path.exists(inventory):
                raise click.ClickException(
                    "Custom inventory file {} doesn't exist".format(inventory))
        else:
            if inventory is not None:
                raise click.ClickException(
                    "-i/--inventory should be specified only when \"--dest custom\" is specified"
                )
            inventory = from_project_root("ansible", "inventories", dest)
        click.echo(
            click.style(
                "Running deployment on {}. This may take a while...".format(
                    inventory),
                fg='magenta'))
        cmd = [ansible, "-i", inventory]
        if dest in ("localhost", ):
            cmd.extend(["-c", "local"])
            if dest == "localhost":
                cmd.append("--sudo")

        if sudo:
            cmd.append('--sudo')

        if ask_sudo_pass:
            cmd.append('--ask-sudo-pass')

        cmd.append(from_project_root("ansible", "site.yml"))
        subprocess.check_call(cmd)
Esempio n. 5
0
def _run_fulltest(extra_args=()):
    command = [from_env_bin("py.test")]
    if extra_args:
        command += list(extra_args)
    else:
        command += ["tests"]
    subprocess.check_call(command, cwd=from_project_root())
Esempio n. 6
0
def testserver(tmux, livereload, port):
    if tmux:
        return _run_tmux_frontend(port=port)
    from flask_app.app import create_app

    extra_files = [from_project_root("flask_app", "app.yml")]

    app = create_app({
        'DEBUG': True,
        'TESTING': True,
        'SECRET_KEY': 'dummy',
        'SECURITY_PASSWORD_SALT': 'dummy'
    })
    logbook.StreamHandler(sys.stderr, level='DEBUG').push_application()
    logbook.compat.redirect_logging()

    if livereload:
        from livereload import Server
        s = Server(app)
        for filename in extra_files:
            s.watch(filename)
        s.watch('flask_app')
        for filename in ['webapp.js', 'vendor.js', 'webapp.css']:
            s.watch(os.path.join('static', 'assets', filename), delay=1)
        s.serve(port=port, liveport=35729)
    else:
        app.run(port=port, extra_files=extra_files)
Esempio n. 7
0
def testserver():
    from flask_app.app import app
    app.config["DEBUG"] = True
    app.config["TESTING"] = True
    app.config["SECRET_KEY"] = "dummy secret key"
    app.run(port=8000, extra_files=[
        from_project_root("flask_app", "app.yml")
    ])
Esempio n. 8
0
def testserver(tmux):
    if tmux:
        return _run_tmux_frontend()
    from flask_app.app import app
    app.config["DEBUG"] = True
    app.config["TESTING"] = True
    app.config["SECRET_KEY"] = "dummy secret key"
    app.run(port=8000, extra_files=[from_project_root("flask_app", "app.yml")])
Esempio n. 9
0
def _run_deploy(dest):
    prepare_source_package()
    cmd = [from_env_bin("python"), from_env_bin("ansible-playbook"), "-i"]
    click.echo(click.style(
        "Running deployment on {0!r}. This may take a while...".format(dest), fg='magenta'))

    cmd.append(from_project_root("ansible", "inventories", dest))
    if dest in ("localhost",):
        cmd.extend(["-c", "local"])
        if dest == "localhost":
            cmd.append("--sudo")
    cmd.append(from_project_root("ansible", "site.yml"))

    if dest == "vagrant":
        subprocess.check_call('vagrant up', shell=True)

        os.environ["ANSIBLE_HOST_KEY_CHECKING"] = 'false'
    subprocess.check_call(cmd)
Esempio n. 10
0
def testserver(tmux):
    if tmux:
        return _run_tmux_frontend()
    from flask_app.app import app
    app.config["DEBUG"] = True
    app.config["TESTING"] = True
    app.config["SECRET_KEY"] = "dummy secret key"
    app.run(port=8000, extra_files=[
        from_project_root("flask_app", "app.yml")
    ])
Esempio n. 11
0
def _run_deploy(dest):
    prepare_source_package()
    ansible = ensure_ansible()
    click.echo(click.style("Running deployment on {0!r}. This may take a while...".format(dest), fg='magenta'))

    if dest == "vagrant":
        # Vagrant will invoke ansible
        environ = os.environ.copy()
        environ["PATH"] = "{}:{}".format(os.path.dirname(ansible), environ["PATH"])
        subprocess.check_call('vagrant up', shell=True, env=environ)
    else:
        cmd = [ansible, "-i",
               from_project_root("ansible", "inventories", dest)]
        if dest in ("localhost",):
            cmd.extend(["-c", "local"])
            if dest == "localhost":
                cmd.append("--sudo")
        cmd.append(from_project_root("ansible", "site.yml"))
        subprocess.check_call(cmd)
Esempio n. 12
0
def testserver(livereload, port):
    from flask_app.app import create_app

    os.environ['CONFIG_DIRECTORY'] = from_project_root("conf.d")

    extra_files=[
        from_project_root("flask_app", "app.yml")
    ]

    app = create_app({'DEBUG': True, 'TESTING': True, 'SECRET_KEY': 'dummy'})
    if livereload:
        from livereload import Server
        s = Server(app)
        for filename in extra_files:
            s.watch(filename)
        s.watch('flask_app')
        s.serve(port=port, liveport=35729)
    else:
        app.run(port=port, extra_files=extra_files)
Esempio n. 13
0
def _run_docker_start(port):
    persistent_dir = from_project_root('persistent')
    if not os.path.isdir(persistent_dir):
        os.makedirs(persistent_dir)
    db_container_name = _db_container_name()
    start_docker_container(image='postgres', name=db_container_name,
                           binds={os.path.join(persistent_dir, "db"):'/var/lib/postgresql/data'})
    container_name = _webapp_container_name()
    start_docker_container(image=APP_NAME, name=container_name, binds={persistent_dir:'/persistent'},
                           port_bindings={80: port},
                           links={db_container_name: 'db'})
Esempio n. 14
0
def testserver(tmux, port):
    if tmux:
        return _run_tmux_frontend(port=port)
    from flask_app.app import create_app

    extra_files=[
        from_project_root("flask_app", "app.yml")
    ]

    app = create_app({'DEBUG': True, 'TESTING': True, 'SECRET_KEY': 'dummy', 'SECURITY_PASSWORD_SALT': 'dummy'})
    logbook.StreamHandler(sys.stderr, level='DEBUG').push_application()
    logbook.compat.redirect_logging()
    app.run(port=port, extra_files=extra_files, use_reloader=False)
Esempio n. 15
0
def deploy(dest, sudo, ask_sudo_pass, vagrant_machine, inventory):
    prepare_source_package()
    ansible = ensure_ansible()

    if dest == "vagrant":
        # Vagrant will invoke ansible
        environ = os.environ.copy()
        environ["PATH"] = "{}:{}".format(os.path.dirname(ansible), environ["PATH"])
        # "vagrant up --provision" doesn't call provision if the virtual machine is already up,
        # so we have to call vagrant provision explicitly
        click.echo(click.style("Running deployment on Vagrant. This may take a while...", fg='magenta'))
        subprocess.check_call('vagrant up ' + vagrant_machine, shell=True, env=environ)
        subprocess.check_call('vagrant provision ' + vagrant_machine, shell=True, env=environ)
    else:
        if dest == "custom":
            if inventory is None:
                raise click.ClickException("-i/--inventory should be specified together with \"--dest custom\"")
            if not os.path.exists(inventory):
                raise click.ClickException("Custom inventory file {} doesn't exist".format(inventory))
        else:
            if inventory is not None:
                raise click.ClickException("-i/--inventory should be specified only when \"--dest custom\" is specified")
            inventory = from_project_root("ansible", "inventories", dest)
        click.echo(click.style("Running deployment on {}. This may take a while...".format(inventory), fg='magenta'))
        cmd = [ansible, "-i", inventory]
        if dest in ("localhost",):
            cmd.extend(["-c", "local"])
            if dest == "localhost":
                cmd.append("--sudo")

        if sudo:
            cmd.append('--sudo')

        if ask_sudo_pass:
            cmd.append('--ask-sudo-pass')

        cmd.append(from_project_root("ansible", "site.yml"))
        subprocess.check_call(cmd)
Esempio n. 16
0
def _run_deploy(dest, sudo=False, ask_sudo_pass=False):
    prepare_source_package()
    ansible = ensure_ansible()
    click.echo(
        click.style(
            "Running deployment on {0!r}. This may take a while...".format(
                dest),
            fg='magenta'))

    if dest == "vagrant":
        # Vagrant will invoke ansible
        environ = os.environ.copy()
        environ["PATH"] = "{}:{}".format(os.path.dirname(ansible),
                                         environ["PATH"])
        # "vagrant up --provision" doesn't call provision if the virtual machine is already up,
        # so we have to call vagrant provision explicitly
        subprocess.check_call('vagrant up', shell=True, env=environ)
        subprocess.check_call('vagrant provision', shell=True, env=environ)
    else:
        cmd = [
            ansible, "-i",
            from_project_root("ansible", "inventories", dest)
        ]
        if dest in ("localhost", ):
            cmd.extend(["-c", "local"])
            if dest == "localhost":
                cmd.append("--sudo")

        if sudo:
            cmd.append('--sudo')

        if ask_sudo_pass:
            cmd.append('--ask-sudo-pass')

        cmd.append(from_project_root("ansible", "site.yml"))
        subprocess.check_call(cmd)
Esempio n. 17
0
def testserver(tmux, port):
    if tmux:
        return _run_tmux_frontend(port=port)
    from flask_app.app import create_app

    extra_files = [from_project_root("flask_app", "app.yml")]

    app = create_app({
        'DEBUG': True,
        'TESTING': True,
        'SECRET_KEY': 'dummy',
        'SECURITY_PASSWORD_SALT': 'dummy'
    })
    logbook.StreamHandler(sys.stderr, level='DEBUG').push_application()
    logbook.compat.redirect_logging()
    app.run(port=port, extra_files=extra_files, use_reloader=False)
Esempio n. 18
0
def testserver(tmux, livereload, port):
    if tmux:
        return _run_tmux_frontend(port=port)
    from flask_app.app import create_app

    extra_files=[
        from_project_root("flask_app", "app.yml")
    ]

    app = create_app({'DEBUG': True, 'TESTING': True, 'SECRET_KEY': 'dummy', 'SECURITY_PASSWORD_SALT': 'dummy'})
    if livereload:
        from livereload import Server
        s = Server(app)
        for filename in extra_files:
            s.watch(filename)
        s.watch('flask_app')
        logbook.StreamHandler(sys.stderr, level='DEBUG').push_application()
        s.serve(port=port, liveport=35729)
    else:
        app.run(port=port, extra_files=extra_files)
Esempio n. 19
0
def testserver(tmux, livereload, port):
    if tmux:
        return _run_tmux_frontend(port=port)
    from flask_app.app import create_app

    extra_files = [from_project_root("flask_app", "app.yml")]

    app = create_app({
        'DEBUG': True,
        'TESTING': True,
        'SECRET_KEY': 'dummy',
        'SECURITY_PASSWORD_SALT': 'dummy'
    })
    if livereload:
        from livereload import Server
        s = Server(app)
        for filename in extra_files:
            s.watch(filename)
        s.watch('flask_app')
        logbook.StreamHandler(sys.stderr, level='DEBUG').push_application()
        s.serve(port=port, liveport=35729)
    else:
        app.run(port=port, extra_files=extra_files)
Esempio n. 20
0
def testserver(tmux, livereload, port):
    if tmux:
        return _run_tmux_frontend(port=port)
    from flask_app.app import create_app

    extra_files=[
        from_project_root("flask_app", "app.yml")
    ]

    app = create_app({'DEBUG': True, 'TESTING': True, 'SECRET_KEY': 'dummy', 'SECURITY_PASSWORD_SALT': 'dummy'})
    if livereload:
        from livereload import Server
        s = Server(app)
        for filename in extra_files:
            s.watch(filename)
        s.watch('flask_app')
        for filename in ['webapp.js', 'vendor.js', 'webapp.css']:
            s.watch(os.path.join('static', 'assets', filename), delay=1)
        logbook.StreamHandler(sys.stderr, level='DEBUG').push_application()
        logbook.compat.redirect_logging()
        s.serve(port=port, liveport=35729)
    else:
        app.run(port=port, extra_files=extra_files)
Esempio n. 21
0
def _run_pytest(pytest_args=()):
    subprocess.check_call(
        [sys.executable, '-m', "pytest"]+list(pytest_args), cwd=from_project_root())
Esempio n. 22
0
def _run_tmux_frontend():
    tmuxp = from_env_bin('tmuxp')
    os.execv(tmuxp, [tmuxp, 'load', from_project_root('_lib', 'frontend_tmux.yml')])
Esempio n. 23
0
def _run_docker_start(port):
    persistent_dir = from_project_root('persistent')
    if not os.path.isdir(persistent_dir):
        os.makedirs(persistent_dir)
    start_docker_container(persistent_dir=persistent_dir,
                           port_bindings={80: port})
Esempio n. 24
0
def _run_pytest(pytest_args=()):
    subprocess.check_call(
        [from_env_bin("py.test")]+list(pytest_args), cwd=from_project_root())
Esempio n. 25
0
def _run_tmux_frontend(port):
    tmuxp = from_env_bin('tmuxp')
    os.execve(tmuxp, [tmuxp, 'load', from_project_root('_lib', 'frontend_tmux.yml')], dict(os.environ, TESTSERVER_PORT=str(port), CONFIG_DIRECTORY=from_project_root("conf.d")))
Esempio n. 26
0
def _run_tmux_frontend(port):
    tmuxp = os.path.join(os.path.dirname(sys.executable), 'tmuxp')
    os.execve(tmuxp, [tmuxp, 'load', from_project_root('_lib', 'frontend_tmux.yml')], dict(os.environ, TESTSERVER_PORT=str(port), CONFIG_DIRECTORY=from_project_root("conf.d")))
Esempio n. 27
0
def _run_unittest():
    subprocess.check_call([
        sys.executable, '-m', "pytest", "tests/", "--cov=flask_app",
        "--cov-report=html"
    ],
                          cwd=from_project_root())
Esempio n. 28
0
def _run_fulltest(extra_args=()):
    subprocess.check_call([sys.executable, '-m', "pytest", "tests"]
                          + list(extra_args), cwd=from_project_root())
Esempio n. 29
0
def _run_docker_build():
    prepare_source_package()
    build_docker_image(tag=APP_NAME, root=from_project_root())
Esempio n. 30
0
def build():
    build_docker_image(tag=APP_NAME, root=from_project_root())
Esempio n. 31
0
def _run_slash(slash_args=()):
    subprocess.check_call(
        [from_env_bin("slash"), "run"]+list(slash_args), cwd=from_project_root())
Esempio n. 32
0
def _run_docker_build():
    prepare_source_package()
    build_docker_image(tag=APP_NAME, root=from_project_root())
Esempio n. 33
0
def _run_pytest(pytest_args=()):
    subprocess.check_call([sys.executable, '-m', "pytest"] + list(pytest_args),
                          cwd=from_project_root())
Esempio n. 34
0
def _run_unittest():
    subprocess.check_call(
        [sys.executable, '-m', "pytest", "tests/", "--cov=flask_app", "--cov-report=html"], cwd=from_project_root())
Esempio n. 35
0
def _run_fulltest(extra_args=()):
    subprocess.check_call([sys.executable, '-m', "pytest", "tests"] +
                          list(extra_args),
                          cwd=from_project_root())
Esempio n. 36
0
def _run_tmux_frontend():
    tmuxp = from_env_bin('tmuxp')
    os.execv(tmuxp,
             [tmuxp, 'load',
              from_project_root('_lib', 'frontend_tmux.yml')])
Esempio n. 37
0
def _run_unittest():
    subprocess.check_call(
        [from_env_bin("py.test"), "tests/test_ut"], cwd=from_project_root())
Esempio n. 38
0
def _run_unittest():
    subprocess.check_call(
        [from_env_bin("py.test"), "tests/", "--cov=flask_app", "--cov-report=html"], cwd=from_project_root())
Esempio n. 39
0
def _run_unittest():
    subprocess.check_call(
        [from_env_bin("py.test"), "tests/", "--cov=flask_app", "--cov-report=html"], cwd=from_project_root())
Esempio n. 40
0
def _run_unittest():
    subprocess.check_call(
        [from_env_bin("py.test"), "tests/test_ut"], cwd=from_project_root())
Esempio n. 41
0
def _run_pytest(pytest_args=()):
    subprocess.check_call(
        [from_env_bin("py.test")]+list(pytest_args), cwd=from_project_root())
Esempio n. 42
0
def _run_fulltest(extra_args=()):
    subprocess.check_call([from_env_bin("py.test"), "tests"]
                          + list(extra_args), cwd=from_project_root())
Esempio n. 43
0
def _run_fulltest(extra_args=()):
    subprocess.check_call([from_env_bin("py.test"), "tests"]
                          + list(extra_args), cwd=from_project_root())
Esempio n. 44
0
def _run_docker_start(port):
    persistent_dir = from_project_root('persistent')
    if not os.path.isdir(persistent_dir):
        os.makedirs(persistent_dir)
    start_docker_container(persistent_dir=persistent_dir, port_bindings={80: port})
Esempio n. 45
0
def _run_slash(slash_args=()):
    subprocess.check_call([from_env_bin("slash"), "run"] + list(slash_args),
                          cwd=from_project_root())