ltdconveyor/cli/upload.py
def upload(ctx, product, git_ref, dirname, aws_id, aws_secret, ci_env,
           on_travis_push, on_travis_pr, on_travis_api, on_travis_cron,
           skip_upload):
    """Upload a new site build to LSST the Docs.
    """
    logger = logging.getLogger(__name__)

    if skip_upload:
        click.echo('Skipping ltd upload.')
        sys.exit(0)

    logger.debug('CI environment: %s', ci_env)
    logger.debug('Travis events settings. '
                 'On Push: %r, PR: %r, API: %r, Cron: %r',
                 on_travis_push, on_travis_pr, on_travis_api, on_travis_cron)

    # Abort upload on Travis CI under certain events
    if ci_env == 'travis' and \
            _should_skip_travis_event(
                on_travis_push, on_travis_pr, on_travis_api, on_travis_cron):
        sys.exit(0)

    # Authenticate to LTD Keeper host
    ensure_login(ctx)

    # Detect git refs
    git_refs = _get_git_refs(ci_env, git_ref)

    build_resource = register_build(
        ctx.obj['keeper_hostname'],
        ctx.obj['token'],
        product,
        git_refs
    )
    logger.debug('Created build resource %r', build_resource)

    # Do the upload.
    # This cache_control is appropriate for builds since they're immutable.
    # The LTD Keeper server changes the cache settings when copying the build
    # over to be a mutable edition.
    upload_dir(
        build_resource['bucket_name'],
        build_resource['bucket_root_dir'],
        dirname,
        aws_access_key_id=aws_id,
        aws_secret_access_key=aws_secret,
        surrogate_key=build_resource['surrogate_key'],
        cache_control='max-age=31536000',
        surrogate_control=None,
        upload_dir_redirect_objects=True)
    logger.debug('Upload complete for %r', build_resource['self_url'])

    # Confirm upload
    confirm_build(
        build_resource['self_url'],
        ctx.obj['token']
    )
    logger.debug('Build %r complete', build_resource['self_url'])
def upload(ctx, product, git_ref, dirname, aws_id, aws_secret, ci_env,
           on_travis_push, on_travis_pr, on_travis_api, on_travis_cron,
           skip_upload):
    """Upload a new site build to LSST the Docs.
    """
    logger = logging.getLogger(__name__)

    if skip_upload:
        click.echo('Skipping ltd upload.')
        sys.exit(0)

    logger.debug('CI environment: %s', ci_env)
    logger.debug('Travis events settings. '
                 'On Push: %r, PR: %r, API: %r, Cron: %r',
                 on_travis_push, on_travis_pr, on_travis_api, on_travis_cron)

    # Abort upload on Travis CI under certain events
    if ci_env == 'travis' and \
            _should_skip_travis_event(
                on_travis_push, on_travis_pr, on_travis_api, on_travis_cron):
        sys.exit(0)

    # Authenticate to LTD Keeper host
    ensure_login(ctx)

    # Detect git refs
    git_refs = _get_git_refs(ci_env, git_ref)

    build_resource = register_build(
        ctx.obj['keeper_hostname'],
        ctx.obj['token'],
        product,
        git_refs
    )
    logger.debug('Created build resource %r', build_resource)

    # Do the upload.
    # This cache_control is appropriate for builds since they're immutable.
    # The LTD Keeper server changes the cache settings when copying the build
    # over to be a mutable edition.
    upload_dir(
        build_resource['bucket_name'],
        build_resource['bucket_root_dir'],
        dirname,
        aws_access_key_id=aws_id,
        aws_secret_access_key=aws_secret,
        surrogate_key=build_resource['surrogate_key'],
        cache_control='max-age=31536000',
        surrogate_control=None,
        upload_dir_redirect_objects=True)
    logger.debug('Upload complete for %r', build_resource['self_url'])

    # Confirm upload
    confirm_build(
        build_resource['self_url'],
        ctx.obj['token']
    )
    logger.debug('Build %r complete', build_resource['self_url'])
def upload ( ctx , product , git_ref , dirname , aws_id , aws_secret , ci_env , on_travis_push , on_travis_pr , on_travis_api , on_travis_cron , skip_upload ) : logger = logging . getLogger ( __name__ ) if skip_upload : click . echo ( 'Skipping ltd upload.' ) sys . exit ( 0 ) logger . debug ( 'CI environment: %s' , ci_env ) logger . debug ( 'Travis events settings. ' 'On Push: %r, PR: %r, API: %r, Cron: %r' , on_travis_push , on_travis_pr , on_travis_api , on_travis_cron ) # Abort upload on Travis CI under certain events if ci_env == 'travis' and _should_skip_travis_event ( on_travis_push , on_travis_pr , on_travis_api , on_travis_cron ) : sys . exit ( 0 ) # Authenticate to LTD Keeper host ensure_login ( ctx ) # Detect git refs git_refs = _get_git_refs ( ci_env , git_ref ) build_resource = register_build ( ctx . obj [ 'keeper_hostname' ] , ctx . obj [ 'token' ] , product , git_refs ) logger . debug ( 'Created build resource %r' , build_resource ) # Do the upload. # This cache_control is appropriate for builds since they're immutable. # The LTD Keeper server changes the cache settings when copying the build # over to be a mutable edition. upload_dir ( build_resource [ 'bucket_name' ] , build_resource [ 'bucket_root_dir' ] , dirname , aws_access_key_id = aws_id , aws_secret_access_key = aws_secret , surrogate_key = build_resource [ 'surrogate_key' ] , cache_control = 'max-age=31536000' , surrogate_control = None , upload_dir_redirect_objects = True ) logger . debug ( 'Upload complete for %r' , build_resource [ 'self_url' ] ) # Confirm upload confirm_build ( build_resource [ 'self_url' ] , ctx . obj [ 'token' ] ) logger . debug ( 'Build %r complete' , build_resource [ 'self_url' ] )
Upload a new site build to LSST the Docs.
Upload a new site build to LSST the Docs .