Python invoke.Collection() Examples

The following are 2 code examples of invoke.Collection(). 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: clean.py    From click-configfile with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def execute_cleanup_tasks(ctx, cleanup_tasks, dry_run=False):
    """Execute several cleanup tasks as part of the cleanup.

    REQUIRES: ``clean(ctx, dry_run=False)`` signature in cleanup tasks.

    :param ctx:             Context object for the tasks.
    :param cleanup_tasks:   Collection of cleanup tasks (as Collection).
    :param dry_run:         Indicates dry-run mode (bool)
    """
    executor = Executor(cleanup_tasks, ctx.config)
    for cleanup_task in cleanup_tasks.tasks:
        print("CLEANUP TASK: %s" % cleanup_task)
        executor.execute((cleanup_task, dict(dry_run=dry_run))) 
Example #2
Source File: __init__.py    From passa with ISC License 5 votes vote down vote up
def add_tasks(module, prefix=None):
    if prefix is None:
        prefix = module.__name__.rsplit('.', 1)[-1]
    child_namespace = invoke.Collection.from_module(module)
    for name in child_namespace.task_names:
        if name in namespace.task_names:
            raise ValueError('duplicate task {}'.format(name))
        namespace.add_task(child_namespace[name], name=name)