Esempio n. 1
0
def deploy_cmd(ctx, server, output_path):
    """This command deploys the entire contents of the build folder
    (`--output-path`) onto a configured remote server.  The name of the
    server must fit the name from a target in the project configuration.
    """
    from lektor.publisher import publish

    if output_path is None:
        output_path = ctx.get_default_output_path()

    ctx.load_plugins()
    env = ctx.get_env()
    config = env.load_config()

    server_info = config.get_server(server)
    if server_info is None:
        raise click.BadParameter('Server "%s" does not exist.' % server,
                                 param_hint='server')

    event_iter = publish(env, server_info.target, output_path)
    if event_iter is None:
        raise click.UsageError('Server "%s" is not configured for a valid '
                               'publishing method.' % server)

    click.echo('Deploying to %s' % server_info.name)
    click.echo('  Build cache: %s' % output_path)
    click.echo('  Target: %s' % secure_url(server_info.target))
    for line in event_iter:
        click.echo('  %s' % click.style(line, fg='cyan'))
    click.echo('Done!')
Esempio n. 2
0
File: cli.py Progetto: jab/lektor
def deploy_cmd(ctx, server, output_path):
    from lektor.publisher import publish

    if output_path is None:
        output_path = ctx.get_default_output_path()

    env = ctx.get_env()
    config = env.load_config()

    server_info = config.get_server(server)
    if server_info is None:
        raise click.BadParameter('Server "%s" does not exist.' % server,
                                 param_hint='server')

    event_iter = publish(env, server_info.target, output_path)
    if event_iter is None:
        raise click.UsageError('Server "%s" is not configured for a valid '
                               'publishing method.' % server)

    click.echo('Deploying to %s' % server_info.name)
    click.echo('  Build cache: %s' % output_path)
    click.echo('  Target: %s' % server_info.target)
    for line in event_iter:
        click.echo('  %s' % click.style(line, fg='cyan'))
    click.echo('Done!')
Esempio n. 3
0
File: cli.py Progetto: jab/lektor
def deploy_cmd(ctx, server, output_path):
    from lektor.publisher import publish

    if output_path is None:
        output_path = ctx.get_default_output_path()

    env = ctx.get_env()
    config = env.load_config()

    server_info = config.get_server(server)
    if server_info is None:
        raise click.BadParameter('Server "%s" does not exist.' % server,
                                 param_hint='server')

    event_iter = publish(env, server_info.target, output_path)
    if event_iter is None:
        raise click.UsageError('Server "%s" is not configured for a valid '
                               'publishing method.' % server)

    click.echo('Deploying to %s' % server_info.name)
    click.echo('  Build cache: %s' % output_path)
    click.echo('  Target: %s' % server_info.target)
    for line in event_iter:
        click.echo('  %s' % click.style(line, fg='cyan'))
    click.echo('Done!')
Esempio n. 4
0
File: api.py Progetto: jab/lektor-1
 def generator():
     try:
         event_iter = publish(info.env, server_info.target,
                              info.output_path) or ()
         for event in event_iter:
             yield {'msg': event}
     except PublishError as e:
         yield {'msg': 'Error: %s' % e}
Esempio n. 5
0
 def generator():
     try:
         event_iter = publish(info.env, server_info.target,
                              info.output_path) or ()
         for event in event_iter:
             yield {'msg': event}
     except PublishError as e:
         yield {'msg': 'Error: %s' % e}
Esempio n. 6
0
def deploy_cmd(ctx, server, output_path, extra_flags, **credentials):
    """This command deploys the entire contents of the build folder
    (`--output-path`) onto a configured remote server.  The name of the
    server must fit the name from a target in the project configuration.
    If no server is supplied then the default server from the config is
    used.

    The deployment credentials are typically contained in the project config
    file but it's also possible to supply them here explicitly.  In this
    case the `--username` and `--password` parameters (as well as the
    `LEKTOR_DEPLOY_USERNAME` and `LEKTOR_DEPLOY_PASSWORD` environment
    variables) can override what's in the URL.

    For more information see the deployment chapter in the documentation.
    """
    from lektor.publisher import publish, PublishError

    if output_path is None:
        output_path = ctx.get_default_output_path()

    ctx.load_plugins(extra_flags=extra_flags)
    env = ctx.get_env()
    config = env.load_config()

    if server is None:
        server_info = config.get_default_server()
        if server_info is None:
            raise click.BadParameter("No default server configured.",
                                     param_hint="server")
    else:
        server_info = config.get_server(server)
        if server_info is None:
            raise click.BadParameter('Server "%s" does not exist.' % server,
                                     param_hint="server")

    try:
        event_iter = publish(
            env,
            server_info.target,
            output_path,
            credentials=credentials,
            server_info=server_info,
            extra_flags=extra_flags,
        )
    except PublishError as e:
        raise click.UsageError('Server "%s" is not configured for a valid '
                               "publishing method: %s" % (server, e))

    click.echo("Deploying to %s" % server_info.name)
    click.echo("  Build cache: %s" % output_path)
    click.echo("  Target: %s" % secure_url(server_info.target))
    try:
        for line in event_iter:
            click.echo("  %s" % click.style(line, fg="cyan"))
    except PublishError as e:
        click.secho("Error: %s" % e, fg="red")
    else:
        click.echo("Done!")
Esempio n. 7
0
def deploy_cmd(ctx, server, output_path, extra_flags, **credentials):
    """This command deploys the entire contents of the build folder
    (`--output-path`) onto a configured remote server.  The name of the
    server must fit the name from a target in the project configuration.
    If no server is supplied then the default server from the config is
    used.

    The deployment credentials are typically contained in the project config
    file but it's also possible to supply them here explicitly.  In this
    case the `--username` and `--password` parameters (as well as the
    `LEKTOR_DEPLOY_USERNAME` and `LEKTOR_DEPLOY_PASSWORD` environment
    variables) can override what's in the URL.

    For more information see the deployment chapter in the documentation.
    """
    from lektor.publisher import publish, PublishError

    if output_path is None:
        output_path = ctx.get_default_output_path()

    ctx.load_plugins()
    env = ctx.get_env()
    config = env.load_config()

    if server is None:
        server_info = config.get_default_server()
        if server_info is None:
            raise click.BadParameter('No default server configured.',
                                     param_hint='server')
    else:
        server_info = config.get_server(server)
        if server_info is None:
            raise click.BadParameter('Server "%s" does not exist.' % server,
                                     param_hint='server')

    try:
        event_iter = publish(env, server_info.target, output_path,
                             credentials=credentials, server_info=server_info,
                             extra_flags=extra_flags)
    except PublishError as e:
        raise click.UsageError('Server "%s" is not configured for a valid '
                               'publishing method: %s' % (server, e))

    click.echo('Deploying to %s' % server_info.name)
    click.echo('  Build cache: %s' % output_path)
    click.echo('  Target: %s' % secure_url(server_info.target))
    try:
        for line in event_iter:
            click.echo('  %s' % click.style(line, fg='cyan'))
    except PublishError as e:
        click.secho('Error: %s' % e, fg='red')
    else:
        click.echo('Done!')
Esempio n. 8
0
 def generator():
     try:
         event_iter = (publish(
             info.env,
             server_info.target,
             info.output_path,
             server_info=server_info,
         ) or ())
         for event in event_iter:
             yield {"msg": event}
     except PublishError as e:
         yield {"msg": "Error: %s" % e}
Esempio n. 9
0
def buildpublish(server):
    # run the build
    builder = current_app.lektor_info.get_builder()
    env = current_app.lektor_info.env
    builder.build_all()
    builder.prune()

    # and then the publish
    db = g.admin_context.pad.db
    config = db.env.load_config()
    server_info = config.get_server(server)
    info = current_app.lektor_info
    event_iter = publish(info.env,
                         server_info.target,
                         info.output_path,
                         server_info=server_info) or ()
    for event in event_iter:
        pass

    # mark this as done
    return True
Esempio n. 10
0
def test_RsyncPublisher_integration(env, tmp_path, delete):
    # Integration test of local rsync deployment
    # Ensures that RsyncPublisher can successfully invoke rsync
    files = {"file.txt": "content\n"}
    output = tmp_path / "output"
    output.mkdir()
    for path, content in files.items():
        output.joinpath(path).write_text(content)

    target_path = tmp_path / "target"
    target_path.mkdir()
    target = f"rsync://{target_path.resolve()}?delete={delete}"

    event_iter = publish(env, target, output)
    for line in event_iter:
        print(line)

    target_files = {
        os.fspath(_.relative_to(target_path)): _.read_text()
        for _ in target_path.iterdir()
    }
    assert target_files == files
Esempio n. 11
0
File: api.py Progetto: jab/lektor
 def generator():
     event_iter = publish(info.env, target, info.output_path) or ()
     for event in event_iter:
         yield {'msg': event}
Esempio n. 12
0
File: api.py Progetto: jab/lektor
 def generator():
     event_iter = publish(info.env, target, info.output_path) or ()
     for event in event_iter:
         yield {'msg': event}