Example #1
0
def update():
    "Builds gettext and updates 'locale/' directory with new files."

    sphinx_builder = 'gettext'

    conf = lazy_conf(None)
    sconf = compute_sphinx_config(sphinx_builder, get_sconf(conf), conf)
    conf = edition_setup(sconf.edition, conf)

    sphinx_prereq(conf)

    try:
        rm_path = os.path.join(conf.paths.projectroot,
                               conf.paths.branch_source, 'meta',
                               'includes.txt')
        os.remove(rm_path)
        print('[tx]: removed {0}'.format(rm_path))
    except OSError:
        pass

    sphinx_build(builder=sphinx_builder,
                 conf=conf,
                 sconf=sconf,
                 finalize_fun=None)

    print('[tx] [sphinx]: rebuild gettext targets')

    tx_cmd = "sphinx-intl update-txconfig-resources --pot-dir {path} --transifex-project-name={name}"

    command(
        tx_cmd.format(path=os.path.join(conf.paths.branch_output,
                                        sphinx_builder),
                      name='-'.join(conf.project.title.lower().split())))

    print('[tx] [sphinx-intl]: updated pot directory')
Example #2
0
def update():
    "Builds gettext and updates 'locale/' directory with new files."

    sphinx_builder = 'gettext'

    conf = lazy_conf(None)
    sconf = get_sconf(conf)
    sconf.builder = sphinx_builder
    sync = StateAttributeDict()

    if 'edition' in sconf:
        conf = edition_setup(sconf.edition, conf)

    # includes_file = os.path.join(conf.paths.branch_source, 'meta', 'includes.txt')
    # if os.path.exists(includes_file):
    #     os.remove(includes_file)

    sphinx_build(builder=sphinx_builder, conf=conf, sconf=sconf, sync=sync, finalize_fun=None)

    print('[tx] [sphinx]: rebuild gettext targets')

    tx_cmd = "sphinx-intl update-txconfig-resources --pot-dir {path} --transifex-project-name={name}"

    command(tx_cmd.format(path=os.path.join(conf.paths.branch_output, sphinx_builder),
                        name='-'.join(conf.project.title.lower().split())))

    print('[tx] [sphinx-intl]: updated pot directory')
Example #3
0
def sphinx_build(targets, conf, sconf, finalize_fun):
    if len(targets) == 0:
        targets.append('html')

    target_jobs = []

    sync = StateAttributeDict()
    for target in targets:
        if target in sconf:
            lsconf = compute_sphinx_config(target, sconf, conf)
            lconf = edition_setup(lsconf.edition, conf)

            target_jobs.append({
                'job': build_worker,
                'args': [ target, lsconf, lconf, sync, finalize_fun],
                'description': "sphinx build worker for {0}".format(target)
            })
        else:
            logger.warning('not building sphinx target {0} without configuration.'.format(target))

    # a batch of prereq jobs go here.
    primer_migrate_pages(conf)
    build_process_prerequsites(sync, conf)

    res = runner(target_jobs, parallel='threads')

    output_sphinx_stream('\n'.join([r[1] if isinstance(r, tuple) else r
                                    for r in res
                                    if r is not None]), conf)

    logger.info('build {0} sphinx targets'.format(len(res)))
Example #4
0
def update():
    "Builds gettext and updates 'locale/' directory with new files."

    sphinx_builder = "gettext"

    conf = lazy_conf(None)
    sconf = compute_sphinx_config(sphinx_builder, get_sconf(conf), conf)
    conf = edition_setup(sconf.edition, conf)

    sphinx_prereq(conf)

    try:
        rm_path = os.path.join(conf.paths.projectroot, conf.paths.branch_source, "meta", "includes.txt")
        os.remove(rm_path)
        print("[tx]: removed {0}".format(rm_path))
    except OSError:
        pass

    sphinx_build(builder=sphinx_builder, conf=conf, sconf=sconf, finalize_fun=None)

    print("[tx] [sphinx]: rebuild gettext targets")

    tx_cmd = "sphinx-intl update-txconfig-resources --pot-dir {path} --transifex-project-name={name}"

    command(
        tx_cmd.format(
            path=os.path.join(conf.paths.branch_output, sphinx_builder),
            name="-".join(conf.project.title.lower().split()),
        )
    )

    print("[tx] [sphinx-intl]: updated pot directory")
Example #5
0
def build_worker(builder, sconf, conf, finalize_fun):
    conf = edition_setup(sconf.edition, conf)

    dirpath = os.path.join(conf.paths.branch_output, builder)
    if not os.path.exists(dirpath):
        os.makedirs(dirpath)
        print('[{0}]: created {1}/{2}'.format(builder, conf.paths.branch_output, builder))

    print('[{0}]: starting {0} build {1}'.format(builder, timestamp()))

    cmd = 'sphinx-build {0} -d {1}/doctrees-{2} {3} {4}' # per-builder-doctreea
    sphinx_cmd = cmd.format(get_sphinx_args(sconf, conf),
                            os.path.join(conf.paths.projectroot, conf.paths.branch_output),
                            builder,
                            os.path.join(conf.paths.projectroot, conf.paths.branch_source),
                            os.path.join(conf.paths.projectroot, conf.paths.branch_output, builder))

    out = command(sphinx_cmd, capture=True)
    # out = sphinx_native_worker(sphinx_cmd)
    print('[build]: completed {0} build at {1}'.format(builder, timestamp()))

    output = '\n'.join([out.err, out.out])

    if out.return_code == 0:
        print('[sphinx]: successfully completed {0} build at {1}!'.format(builder, timestamp()))
        if finalize_fun is not None:
            finalize_fun(builder, sconf, conf)
            print('[sphinx]: finalized {0} build at {1}'.format(builder, timestamp()))
        return output
    else:
        print('[sphinx]: the {0} build was not successful. not running finalize steps'.format(builder))
        output_sphinx_stream(output, conf)
        return None
Example #6
0
def sphinx_build(targets, conf, sconf, finalize_fun):
    if len(targets) == 0:
        targets.append('html')

    target_jobs = []

    sync = StateAttributeDict()
    for target in targets:
        if target in sconf:
            lsconf = compute_sphinx_config(target, sconf, conf)
            lconf = edition_setup(lsconf.edition, conf)

            target_jobs.append({
                'job': build_worker,
                'args': [ target, lsconf, lconf, sync, finalize_fun]
            })
        else:
            print('[sphinx] [warning]: not building {0} without configuration.'.format(target))

    # a batch of prereq jobs go here.
    primer_migrate_pages(conf)
    build_process_prerequsites(conf)

    if len(target_jobs) <= 1:
        res = runner(target_jobs, pool=1)
    else:
        res = runner(target_jobs, parallel='threads')

    output_sphinx_stream('\n'.join([r for r in res if r is not None]), conf)

    print('[sphinx]: build {0} sphinx targets'.format(len(res)))
Example #7
0
def conf(edition=None, conf=None):
    "Returns the build configuration object for visual introspection. Optionally specify 'edition' argument."

    if conf is None:
        conf = get_conf()
    if edition is not None:
        conf = edition_setup(edition, conf)

    puts(json.dumps(conf, indent=3))
Example #8
0
def conf(edition=None, conf=None):
    "Returns the build configuration object for visual introspection. Optionally specify 'edition' argument."

    if conf is None:
        conf = get_conf()
    if edition is not None:
        conf = edition_setup(edition, conf)

    puts(json.dumps(conf, indent=3))
Example #9
0
def deploy_jobs(target, conf, pconf):
    if 'edition' in pconf:
        conf = edition_setup(pconf.edition, conf)

    if 'recursive' in pconf.options:
        env.rsync_options.recursive = True
    if 'delete' in pconf.options:
        env.rsync_options.delete = True

    if pconf.env in ['publication', 'mms']:
        hosts = _pub_hosts
        deploy_target = 'production'
    elif pconf.env.startswith('stag'):  # staging or stage
        deploy_target = 'staging'
        hosts = _stage_hosts
    else:
        abort('[deploy]: must specify a valid host to deploy the docs to.')

    args = dict(local_path=get_branched_path(pconf.options, conf,
                                             conf.paths.output,
                                             pconf.paths.local),
                remote=get_branched_path(pconf.options, conf,
                                         pconf.paths.remote),
                host_string=None,
                recursive=env.rsync_options.recursive,
                delete=env.rsync_options.delete,
                environ=deploy_target,
                pconf=pconf,
                conf=conf)

    for host in hosts:
        args['host_string'] = host
        yield {
            'job': static_worker if 'static' in pconf.options else push_worker,
            'args': args.copy(),
            'target': None,
            'dependency': None
        }

    try:
        if isinstance(pconf.paths.static, list):
            for static_path in pconf.paths.static:
                for job in static_deploy(args, static_path, hosts, conf,
                                         pconf):
                    yield job
        else:
            for job in static_deploy(args, pconf.paths.static, hosts, conf,
                                     pconf):
                yield job
    except AttributeError:
        puts('[deploy] [ERROR]: not deploying any static content')
Example #10
0
def deploy_jobs(target, conf, pconf):
    if 'edition' in pconf:
        conf = edition_setup(pconf.edition, conf)

    if 'recursive' in pconf.options:
        env.rsync_options.recursive = True
    if 'delete' in pconf.options:
        env.rsync_options.delete = True

    if pconf.env in ['publication', 'mms']:
        hosts = _pub_hosts
        deploy_target = 'production'
    elif pconf.env.startswith('stag'): # staging or stage
        deploy_target = 'staging'
        hosts = _stage_hosts
    else:
        abort('[deploy]: must specify a valid host to deploy the docs to.')


    args = dict(local_path=get_branched_path(pconf.options, conf, conf.paths.output, pconf.paths.local),
                remote=get_branched_path(pconf.options, conf, pconf.paths.remote),
                host_string=None,
                recursive=env.rsync_options.recursive,
                delete=env.rsync_options.delete,
                environ=deploy_target,
                pconf=pconf,
                conf=conf)

    for host in hosts:
        args['host_string'] = host
        yield { 'job': static_worker if 'static' in pconf.options else push_worker,
                'args': args.copy(),
                'target': None,
                'dependency': None }

    try:
        if isinstance(pconf.paths.static, list):
            for static_path in pconf.paths.static:
                for job in static_deploy(args, static_path, hosts, conf, pconf):
                    yield job
        else:
            for job in static_deploy(args, pconf.paths.static, hosts, conf, pconf):
                yield job
    except AttributeError:
        puts('[deploy] [ERROR]: not deploying any static content')
Example #11
0
def update():
    "Builds gettext and updates 'locale/' directory with new files."

    sphinx_builder = 'gettext'

    conf = lazy_conf(None)
    sconf = get_sconf(conf)
    sconf.builder = sphinx_builder
    sync = StateAttributeDict()

    if 'edition' in sconf:
        conf = edition_setup(sconf.edition, conf)

    # includes_file = os.path.join(conf.paths.branch_source, 'meta', 'includes.txt')
    # if os.path.exists(includes_file):
    #     os.remove(includes_file)

    sphinx_build(builder=sphinx_builder,
                 conf=conf,
                 sconf=sconf,
                 sync=sync,
                 finalize_fun=None)
    logger.info('rebuilt gettext targets')

    tx_cmd = "sphinx-intl update-txconfig-resources --pot-dir {path} --transifex-project-name={name}"

    logger.info('updating translation artifacts. Long running.')
    r = command(tx_cmd.format(
        path=os.path.join(conf.paths.branch_output, sphinx_builder),
        name='-'.join(conf.project.title.lower().split())),
                capture=True,
                ignore=True)

    if r.return_code != 0:
        logger.critical('uploading translations failed.')
        logger.warning(r.err)
        raise SystemExit
    else:
        logger.info(r.out)
        logger.info(
            'sphinx_intl completed successfully: translation uploaded.')

    logger.info('sphinx-intl: updated pot directory')
    check()
    logger.info('completed translation file check.')
Example #12
0
def conf(*modifications):
    "Returns the build configuration object for visual introspection. Optionally specify 'edition' argument."

    conf = lazy_conf(None)

    if modifications:
        if isinstance(modifications, tuple) and len(modifications) <= 2:
            pass
        else:
            modifications = [modifications]

        for mod in modifications:
            if len(mod) == 2:
                sconf = AttributeDict({'language': mod})
                conf = language_setup(sconf, conf)
            else:
                conf = edition_setup(mod, conf)

    puts(json.dumps(conf, indent=3))
Example #13
0
def sphinx_build(targets, conf, sconf, finalize_fun):
    if len(targets) == 0:
        targets.append('html')

    sconf = render_sphinx_config(sconf)

    target_jobs = []

    sync = StateAttributeDict()
    for target in targets:
        if target in sconf:
            lsconf = compute_sphinx_config(target, sconf, conf)
            lconf = edition_setup(lsconf, conf)
            lconf = language_setup(lsconf, lconf)

            target_jobs.append({
                'job':
                build_worker,
                'args': [target, lsconf, lconf, sync, finalize_fun],
                'description':
                "sphinx build worker for {0}".format(target)
            })
        else:
            logger.warning(
                'not building sphinx target {0} without configuration.'.format(
                    target))

    # a batch of prereq jobs go here.
    primer_migrate_pages(conf)
    build_process_prerequsites(sync, conf)

    res = runner(target_jobs, parallel='threads')

    output_sphinx_stream(
        '\n'.join([
            r[1] if isinstance(r, tuple) else r for r in res if r is not None
        ]), conf)

    logger.info('build {0} sphinx targets'.format(len(res)))
Example #14
0
def update():
    "Builds gettext and updates 'locale/' directory with new files."

    sphinx_builder = 'gettext'

    conf = lazy_conf(None)
    sconf = get_sconf(conf)
    sconf.builder = sphinx_builder
    sync = StateAttributeDict()

    if 'edition' in sconf:
        conf = edition_setup(sconf.edition, conf)

    # includes_file = os.path.join(conf.paths.branch_source, 'meta', 'includes.txt')
    # if os.path.exists(includes_file):
    #     os.remove(includes_file)

    sphinx_build(builder=sphinx_builder, conf=conf, sconf=sconf, sync=sync, finalize_fun=None)
    logger.info('rebuilt gettext targets')

    tx_cmd = "sphinx-intl update-txconfig-resources --pot-dir {path} --transifex-project-name={name}"

    logger.info('updating translation artifacts. Long running.')
    r = command(tx_cmd.format(path=os.path.join(conf.paths.branch_output, sphinx_builder),
                              name='-'.join(conf.project.title.lower().split())),
                capture=True, ignore=True)


    if r.return_code != 0:
        logger.critical('uploading translations failed.')
        logger.warning(r.err)
        raise SystemExit
    else:
        logger.info(r.out)
        logger.info('sphinx_intl completed successfully: translation uploaded.')

    logger.info('sphinx-intl: updated pot directory')
    check()
    logger.info('completed translation file check.')