Python invoke.task() Examples

The following are 23 code examples of invoke.task(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module invoke , or try the search function .
Example #1
Source File: tasks.py    From python-hpedockerplugin with Apache License 2.0 6 votes vote down vote up
def release(ctx, sdist=True, wheel=True, sign=True, dry_run=False):
    """
    Wraps invocations.packaging.publish to add baked-in docs folder.
    """
    # Build docs first. Use terribad workaround pending invoke #146
    ctx.run("inv docs", pty=True, hide=False)
    # Move the built docs into where Epydocs used to live
    target = 'docs'
    rmtree(target, ignore_errors=True)
    # TODO: make it easier to yank out this config val from the docs coll
    copytree('sites/docs/_build', target)
    # Publish
    publish(ctx, sdist=sdist, wheel=wheel, sign=sign, dry_run=dry_run)
    # Remind
    print("\n\nDon't forget to update RTD's versions page for new minor "
          "releases!")


# TODO: "replace one task with another" needs a better public API, this is
# using unpublished internals & skips all the stuff add_task() does re:
# aliasing, defaults etc. 
Example #2
Source File: tasks.py    From kartotherian_docker with Apache License 2.0 6 votes vote down vote up
def load_all(ctx):
    """
    default task called if `invoke` is run without args

    This is the main tasks that import all the datas into postgres and start the tiles generation process
    """
    if not ctx.osm.file and not ctx.osm.url:
        raise Exception("you should provide a osm.file variable or osm.url variable")

    lock_path = get_import_lock_path(ctx)
    with FileLock(lock_path) as lock:
        prepare_db(ctx)
        load_osm(ctx)
        load_additional_data(ctx)
        run_post_sql_scripts(ctx)

        if ctx.wikidata.stats.enabled:
            override_wikidata_weight_functions(ctx)

        rotate_database(ctx)
        generate_tiles(ctx)
        init_osm_update(ctx) 
Example #3
Source File: docs.py    From django-radio with GNU General Public License v3.0 6 votes vote down vote up
def build(ctx):
    ctx.run("sphinx-apidoc -f -o docs/source/source_code .")
    ctx.run("sphinx-build -b html -d docs/build/doctrees -D latex_paper_size=a4 docs/source docs/build/html")


# import os
#
# from utils import chdir, BASE_DIR
# DOCS_DIR = os.path.join(BASE_DIR, 'docs/')
#
#
# @task
# def build_translation(ctx):
#     with chdir(DOCS_DIR):
#         # ctx.run('make gettext') to create initial locales
#         # ctx.run('sphinx-intl update -p build/locale -l es') to create initial locales
#         ctx.run('sphinx-intl update -p build/locale') 
Example #4
Source File: test.py    From flexx with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def test(ctx, unit='', style='', cover=False):
    """ run tests (unit, style)
    """

    if not (unit or style or cover):
        sys.exit('Test task needs --unit, --style or --cover')
    if unit:
        test_unit('.' if not isinstance(unit, str) else unit)
    if style:
        test_style('.' if not isinstance(style, str) else style)
    if cover:
        show_coverage_html() 
Example #5
Source File: tasks.py    From compas_fab with MIT License 5 votes vote down vote up
def help(ctx):
    """Lists available tasks and usage."""
    ctx.run('invoke --list')
    log.write('Use "invoke -h <taskname>" to get detailed help for a task.') 
Example #6
Source File: tasks.py    From compas with MIT License 5 votes vote down vote up
def help(ctx):
    """Lists available tasks and usage."""
    ctx.run('invoke --list')
    log.write('Use "invoke -h <taskname>" to get detailed help for a task.') 
Example #7
Source File: tasks.py    From roslibpy with MIT License 5 votes vote down vote up
def help(ctx):
    """Lists available tasks and usage."""
    ctx.run('invoke --help')
    ctx.run('invoke --list')
    log.write('Use "invoke -h <taskname>" to get detailed help for a task.') 
Example #8
Source File: __init__.py    From requirementslib with MIT License 5 votes vote down vote up
def log(task, message, level=LogLevel.INFO):
    message_format = f"[{level.name.upper()}] "
    if level.value >= LogLevel.ERROR.value:
        task = f"****** ({task}) "
    else:
        task = f"({task}) "
    print(f"{message_format}{task}{message}", file=sys.stderr) 
Example #9
Source File: help.py    From pscript with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def help(ctx):
    """Get info on usage.
    """

    print('Developer tools for project %s\n' % NAME.capitalize())
    print('  invoke <task> [arg] to run a task')
    print('  invoke --help <task> to get info on a task')
    print()
    subprocess.call('invoke --list') 
Example #10
Source File: test.py    From pscript with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def test(ctx, unit='', style='', cover=False):
    """ run tests (unit, style)
    """
    
    if not (unit or style or cover):
        sys.exit('Test task needs --unit, --style or --cover')
    if unit:
        test_unit('.' if not isinstance(unit, str) else unit)
    if style:
        test_style('.' if not isinstance(style, str) else style)
    if cover:
        show_coverage_html() 
Example #11
Source File: tasks.py    From gatorgrader with GNU General Public License v3.0 5 votes vote down vote up
def test(c, pyenv):
    """Run tests with Pytest after full setup of each provided Pyenv version."""
    # Note that this task will leave a developer in the last specified version of Python
    # run the test suite for all of the provided versions of Python managed by Pyenv
    for current_pyenv in pyenv:
        print("Python version: " + current_pyenv)
        internal_switch(c, current_pyenv)
        # run the test suite
        internal_cover(c, cover=False) 
Example #12
Source File: tasks.py    From gatorgrader with GNU General Public License v3.0 5 votes vote down vote up
def cover(c, pyenv):
    """Run coverage-monitored tests with Pytest after full setup of each provided Pyenv version."""
    # Note that this task will leave a developer in the last specified version of Python
    # run the test suite for all of the provided versions of Python managed by Pyenv
    for current_pyenv in pyenv:
        print("Python version: " + current_pyenv)
        internal_switch(c, current_pyenv)
        # run the test suite and collect coverage information
        internal_cover(c, cover=True) 
Example #13
Source File: help.py    From flexx with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def help(ctx):
    """Get info on usage.
    """

    print('Developer tools for project %s\n' % NAME.capitalize())
    print('  invoke <task> [arg] to run a task')
    print('  invoke --help <task> to get info on a task')
    print()
    subprocess.call('invoke --list') 
Example #14
Source File: release.py    From PySpice with GNU General Public License v3.0 5 votes vote down vote up
def install(ctx):
    ctx.run('python3 setup.py install')

# @task(clean, build)
# def sdist(ctx):
#     ctx.run('python3 setup.py sdist')

# @task(clean, build)
# def bdist(ctx):
#     ctx.run('python3 setup.py bdist') 
Example #15
Source File: tasks.py    From aiohttp-utils with MIT License 5 votes vote down vote up
def watch_docs(ctx, browse=False):
    """Run build the docs when a file changes."""
    try:
        import sphinx_autobuild  # noqa
    except ImportError:
        print('ERROR: watch task requires the sphinx_autobuild package.')
        print('Install it with:')
        print('    pip install sphinx-autobuild')
        sys.exit(1)
    ctx.run('sphinx-autobuild {0} {1} {2} -z aiohttp_utils'.format(
        '--open-browser' if browse else '', docs_dir, build_dir), echo=True, pty=True) 
Example #16
Source File: clean.py    From click-configfile with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def clean_all(ctx, dry_run=False):
    """Clean up everything, even the precious stuff.
    NOTE: clean task is executed first.
    """
    cleanup_dirs(ctx.clean_all.directories or [], dry_run=dry_run)
    cleanup_dirs(ctx.clean_all.extra_directories or [], dry_run=dry_run)
    cleanup_files(ctx.clean_all.files or [], dry_run=dry_run)
    cleanup_files(ctx.clean_all.extra_files or [], dry_run=dry_run)
    execute_cleanup_tasks(ctx, cleanup_all_tasks, dry_run=dry_run)
    clean(ctx, dry_run=dry_run) 
Example #17
Source File: copy.py    From okcupyd with MIT License 5 votes vote down vote up
def build_copy_task(method):
    @task
    def copy_task(source_credentials, dest_credentials):
        copy = build_copy(source_credentials, dest_credentials)
        getattr(copy, method)()
    ns.add_task(copy_task, name=method) 
Example #18
Source File: util.py    From okcupyd with MIT License 5 votes vote down vote up
def build_task_factory(ns):
    @curry
    def task_decorator(function, **kwargs):
        name = kwargs.pop("name", None)
        default = kwargs.pop("default", None)
        created_task = task(function, **kwargs)
        ns.add_task(created_task, name=name, default=default)
        return created_task
    return task_decorator 
Example #19
Source File: tasks.py    From kartotherian_docker with Apache License 2.0 5 votes vote down vote up
def run_osm_update(ctx):
    if not check_generated_cache(ctx.generated_files_dir):
        sys.exit(1)

    change_file_path = f"{ctx.update_tiles_dir}/changes.osc.gz"
    lock_path = get_import_lock_path(ctx)
    with FileLock(lock_path) as lock:
        current_osm_timestamp = read_current_state(ctx)
        try:
            osmupdate_opts = _get_osmupdate_options(ctx)
            ctx.run(
                f'osmupdate {osmupdate_opts} {current_osm_timestamp} {change_file_path}'
            )
        except Failure as exc:
            if exc.result.return_code == 21:
                logging.info('OSM state is up to date, no change to apply')
                return
            raise

        new_osm_timestamp = read_osm_timestamp(ctx, change_file_path)

        osm_update(
            ctx,
            f"postgis://{ctx.pg.user}:{ctx.pg.password}@{ctx.pg.host}:{ctx.pg.port}/{ctx.pg.database}",
            ctx.update_tiles_dir,
            ctx.generated_files_dir,
            ctx.imposm_config_dir,
            change_file_path
        )
        write_new_state(ctx, new_osm_timestamp)
        os.remove(change_file_path)


# default task
############## 
Example #20
Source File: tasks.py    From kartotherian_docker with Apache License 2.0 5 votes vote down vote up
def reindex_poi_geometries(ctx):
    """
    Successive updates tend to bloat some of the geometry indexes significantly.
    This task triggers a forced REINDEX after the update has been applied.
    """
    if not ctx.osm_update.reindex_poi_geometries:
        return
    _execute_sql(ctx, "REINDEX (VERBOSE) INDEX osm_poi_polygon_geom", db=ctx.pg.database) 
Example #21
Source File: tasks.py    From nplusone with MIT License 5 votes vote down vote up
def watch_docs(ctx):
    """Run build the docs when a file changes."""
    try:
        import sphinx_autobuild  # noqa
    except ImportError:
        print('ERROR: watch task requires the sphinx_autobuild package.')
        print('Install it with:')
        print('    pip install sphinx-autobuild')
        sys.exit(1)
    docs(ctx)
    ctx.run('sphinx-autobuild {} {}'.format(docs_dir, build_dir), pty=True) 
Example #22
Source File: tasks.py    From flask-apispec with MIT License 5 votes vote down vote up
def watch_docs(ctx, browse=False):
    """Run build the docs when a file changes."""
    try:
        import sphinx_autobuild  # noqa
    except ImportError:
        print('ERROR: watch task requires the sphinx_autobuild package.')
        print('Install it with:')
        print('    pip install sphinx-autobuild')
        sys.exit(1)
    ctx.run('sphinx-autobuild {0} {1} {2} -z marshmallow'.format(
        '--open-browser' if browse else '', docs_dir, build_dir), echo=True, pty=True) 
Example #23
Source File: tasks.py    From hpack with MIT License 4 votes vote down vote up
def hpack():
    """
    This task generates HPACK test data suitable for use with
    https://github.com/http2jp/hpack-test-case

    The current format defines a JSON object with three keys: 'draft',
    'description' and 'cases'.

    The cases key has as its value a list of objects, with each object
    representing a set of headers and the output from the encoder. The object
    has the following keys:

    - 'header_table_size': the size of the header table used.
    - 'headers': A list of the headers as JSON objects.
    - 'wire': The output from the encoder in hexadecimal.
    """
    # A generator that contains the paths to all the raw data files and their
    # names.
    raw_story_files = (
        (os.path.join('test/test_fixtures/raw-data', name), name)
        for name in os.listdir('test/test_fixtures/raw-data')
    )

    # For each file, build our output.
    for source, outname in raw_story_files:
        with open(source, 'rb') as f:
            indata = json.load(f)

        # Prepare the output and the encoder.
        output = {
            'description': 'Encoded by hyper. See github.com/Lukasa/hyper for more information.',
            'cases': []
        }
        e = Encoder()

        for case in indata['cases']:
            outcase = {
                'header_table_size': e.header_table_size,
                'headers': case['headers'],
            }
            headers = []

            for header in case['headers']:
                key = header.keys()[0]
                header = (key, header[key])
                headers.append(header)

            outcase['wire'] = hexlify(e.encode(headers))
            output['cases'].append(outcase)

        with open(outname, 'wb') as f:
            f.write(json.dumps(output, sort_keys=True,
                    indent=2, separators=(',', ': ')))