Пример #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')
Пример #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')
Пример #3
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")
Пример #4
0
def build_worker(builder, sconf, conf, sync, finalize_fun):
    dirpath = os.path.join(conf.paths.branch_output, builder)
    if not os.path.exists(dirpath):
        os.makedirs(dirpath)
        logger.info('created directories "{1}" for sphinx builder {0}'.format(builder, dirpath))

    # a batch of prereq jobs go here. (if they need the modified conf.)
    build_job_prerequsites(sync, sconf, conf)

    logger.info('starting sphinx build {0} at {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, ignore=True)
    # out = sphinx_native_worker(sphinx_cmd)
    logger.info('completed sphinx build {0} at {1}'.format(builder, timestamp()))

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

    if out.return_code == 0:
        logger.info('successfully completed {0} sphinx build at {1}!'.format(builder, timestamp()))
        if finalize_fun is not None:
            finalize_fun(builder, sconf, conf)
            logger.info('finalized sphinx {0} build at {1}'.format(builder, timestamp()))
        return output
    else:
        logger.warning('the sphinx build {0} was not successful. not running finalize steps'.format(builder))
        output_sphinx_stream(output, conf)
        return None
Пример #5
0
def _render_tex_into_pdf(fn, path):
    pdflatex = 'TEXINPUTS=".:{0}:" pdflatex --interaction batchmode --output-directory {0} {1}'.format(
        path, fn)

    base_fn = os.path.basename(fn)
    cmds = [
        pdflatex,
        "makeindex -s {0}/python.ist {0}/{1}.idx ".format(path, base_fn[:-4]),
        pdflatex, pdflatex
    ]

    for idx, cmd in enumerate(cmds):
        r = command(command=cmd, ignore=True)

        if r.succeeded is True:
            logger.info(
                'pdf completed rendering stage {0} of {1} successfully.'.
                format(idx, len(cmds)))
        else:
            if idx <= 1:
                logger.warning(
                    'pdf build encountered error early on {0}, continuing cautiously.'
                    .format(base_fn))
                continue
            else:
                logger.error(
                    'pdf build encountered error running pdflatex, investigate on {0}. terminating'
                    .format(base_fn))
                return False
Пример #6
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
Пример #7
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.')
Пример #8
0
def build_worker(builder, sconf, conf, sync, finalize_fun):
    dirpath = os.path.join(conf.paths.branch_output, builder)
    if not os.path.exists(dirpath):
        os.makedirs(dirpath)
        logger.info('created directories "{1}" for sphinx builder {0}'.format(
            builder, dirpath))

    # a batch of prereq jobs go here. (if they need the modified conf.)
    build_job_prerequsites(sync, sconf, conf)

    logger.info('starting sphinx build {0} at {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, ignore=True)
    # out = sphinx_native_worker(sphinx_cmd)
    logger.info('completed sphinx build {0} at {1}'.format(
        builder, timestamp()))

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

    if out.return_code == 0:
        logger.info('successfully completed {0} sphinx build at {1}!'.format(
            builder, timestamp()))
        if finalize_fun is not None:
            finalize_fun(builder, sconf, conf)
            logger.info('finalized sphinx {0} build at {1}'.format(
                builder, timestamp()))
        return output
    else:
        logger.warning(
            'the sphinx build {0} was not successful. not running finalize steps'
            .format(builder))
        output_sphinx_stream(output, conf)
        return None
Пример #9
0
def _render_tex_into_pdf(fn, path):
    pdflatex = 'TEXINPUTS=".:{0}:" pdflatex --interaction batchmode --output-directory {0} {1}'.format(path, fn)

    base_fn = os.path.basename(fn)
    cmds = [ pdflatex,
             "makeindex -s {0}/python.ist {0}/{1}.idx ".format(path, base_fn[:-4]),
             pdflatex,
             pdflatex ]

    for idx, cmd in enumerate(cmds):
        r = command(command=cmd, ignore=True)

        if r.succeeded is True:
            logger.info('pdf completed rendering stage {0} of {1} successfully.'.format(idx, len(cmds)))
        else:
            if idx <= 1:
                logger.warning('pdf build encountered error early on {0}, continuing cautiously.'.format(base_fn))
                continue
            else:
                logger.error('pdf build encountered error running pdflatex, investigate on {0}. terminating'.format(base_fn))
                return False
Пример #10
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.')
Пример #11
0
def push():
    "Runs 'tx push' command."
    command('tx push -s -t')
Пример #12
0
def push():
    "Runs 'tx push' command."
    command("tx push -s -t")
Пример #13
0
def push():
    "Runs 'tx push' command."
    command('tx push -s -t')
Пример #14
0
def logged_command(verb, cmd):
    r = command(cmd, capture=True)
    logger.info('{0}ed {1}'.format(verb, cmd.split(' ')[-1]))

    return r.out
Пример #15
0
def logged_command(verb, cmd):
    r = command(cmd, capture=True)
    logger.info('{0}ed {1}'.format(verb, cmd.split(' ')[-1]))

    return r.out